//
//  SendGoodsVC.m
//  NtoccShipper
//
//  Created by mac on 2019/11/12.
//  Copyright © 2019 zhuchongjin. All rights reserved.
//

#import "SendGoodsVC.h"
#import "SendGoodsCell.h"
#import "DefaultSettingVC.h"
#import "CommonRouteVC.h"
#import "CommonRouteModel.h"
#import "AddNewCommonRouteVC.h"
#import "SelectGoodsNameVC.h"
#import "SelectGoodsNameCellModel.h"
#import "UpstreamCustomerVC.h"
#import "UseCarTypesVC.h"
#import "SelectDriverVC.h"
#import "DriverListModel.h"
#import "CommonGoodsSourceVC.h"
#import "CJWKWebViewVC.h"
#import "DefaultSettingModel.h"
#import "UpstreamCustomerModel.h"
#import "HDPicModle.h"
#import "GetPhoto.h"
#import "MyImgVAlertView.h"
#import "SubordIndustryVC.h"
#import "GetPhoto.h"
#import "XLImageViewer.h"
#import "JieSuanDriverController.h"

@interface SendGoodsVC ()<UITableViewDelegate,UITableViewDataSource ,UITextFieldDelegate>{
    
    FlexFrameView *header;
    FlexFrameView * topView;
    FlexFrameView *bottomView;
}
// 发货的 顶部
@property (nonatomic,copy) NSString *strIsSetDefault; // 是否默认 1
@property (strong, nonatomic) CJImageView *imgVSetDefault;
// 功能按钮是否高亮
@property (nonatomic,strong) FlexTouchView *touchCommonRoute;
@property (nonatomic,strong) CJLabel *labtouchCommonRoute;
@property (nonatomic,strong) FlexTouchView *touchAddNewRoute;
@property (nonatomic,strong) CJLabel *labtouchAddNewRoute;
@property (nonatomic,strong) FlexTouchView *touchCommonSendSources;
@property (nonatomic,strong) CJLabel *labtouchCommonSendSources;

@property (nonatomic,strong) CJView *viewAdress; // 地址view
@property (nonatomic,strong) CJLabel *labUploadName;
@property (nonatomic,strong) CJLabel *labUploadPhone;
@property (nonatomic,strong) CJLabel *labUploadAdress;
@property (nonatomic,copy) NSString *strUploadDetailAdress;
@property (nonatomic,copy) NSString *strUploadAdress;

@property (nonatomic,strong) CJLabel *labDownloadName;
@property (nonatomic,strong) CJLabel *labDownloadPhone;
@property (nonatomic,strong) CJLabel *labDownloadAdress;
@property (nonatomic,copy) NSString *strDownloadDetailAdress;
@property (nonatomic,copy) NSString *strDownloadAdress;

@property (nonatomic,strong) NSString *strUploadCountyCode;
@property (nonatomic,strong) NSString *strDownloadCountyCode;

@property (nonatomic,strong) CJTableView *tableView;
@property (nonatomic,strong) SendGoodsCell *sendGoodsCell;

@property (strong, nonatomic) CJTextField *fieldGoodsName;
@property (strong, nonatomic) CJTextField *selectedDriverTextField;
@property (nonatomic,copy) NSDictionary *dicGoodsName;
@property (nonatomic,copy) NSString *strGoodsNameCodes; //货物名称的code
@property (nonatomic,copy) NSString *strGoodsSmallName;
@property (nonatomic,copy) NSString *strGoodsBigTypeCode; //货物大类code
@property (nonatomic,copy) NSString *strGoodsBigTypeName;

// 所属行业
@property (nonatomic ,strong) UIView *viewIndustry;
@property (strong, nonatomic) CJTextField *fieldIndustryName;
@property (nonatomic,copy) NSDictionary *dicIndustryName;
@property (nonatomic,copy) NSString *strIndustryNameCodes;
@property (nonatomic,copy) NSString *strIndustrySmallName;
@property (nonatomic,copy) NSString *strIndustryBigTypeCode;
@property (nonatomic,copy) NSString *strIndustryBigTypeName;


@property (nonatomic,strong) CJTextField *fieldGoodsNum; // 货物数量
@property (nonatomic,strong) CJLabel *labGoodsTransferFeeUnits;//货物数量单位
@property (nonatomic,copy) NSString *strGoodsTransferFeeUnits; //货物单位 0：吨 1：立方米，2-件 ,
@property (nonatomic,strong) CJLabel *labGoodsNumUnit;
@property (strong, nonatomic) CJTextField *fieldGoodsPrice; // 单价
@property (strong, nonatomic) CJLabel *labGoodsPriceUnit;
@property (strong, nonatomic) CJTextField *fleidLoss; //损耗

@property (nonatomic,strong) FlexTouchView *touchViewLoss;
@property (strong, nonatomic) CJLabel *labLossUnit;
@property (nonatomic,copy) NSString *strLossCode;

@property (strong, nonatomic) CJTextField *fieldFreightCost; // 运费单价
@property (strong, nonatomic) CJLabel *labFreightCostUnit;
@property (nonatomic,copy) NSString *strFreightCostUnit;


@property (strong, nonatomic) CJTextField *fieldCarNumsRequir; // 车数要求
@property (nonatomic,strong) UILabel *labCarNumsRequir; // 车数要求是否

@property (strong, nonatomic) CJTextField *fieldUpLoadGoodsTime; //装车时间
@property (strong, nonatomic) CJTextField *fieldDomnLoadCoodsTime; //卸车时间
@property (strong, nonatomic) CJLabel *labDistance; // 距离
//@property (nonatomic,strong) UISwitch *switchInSure; // 投保
@property (nonatomic,strong) UISwitch *switchInSure;
@property (nonatomic,copy) NSString *strIsInsure; //投保类别：0-不投保 1
@property (strong, nonatomic) CJTextField *fieldInSureMoney; // 投保金额
@property (nonatomic,copy) NSString *strInSureMoneyCode;
@property (nonatomic,strong) UIView *viewInSureMoney;

@property (strong, nonatomic) CJTextField *fieldAppointDriver; //指定司机
@property (nonatomic,copy) NSString *strAppointDriverCode; // 指定司机code
@property (nonatomic,strong) UILabel *labAppointDriverWran;
@property (strong, nonatomic) CJTextField *fieldUserCarType; //用车类型
@property (nonatomic,copy) NSDictionary *dicUserCarType;
@property (nonatomic,strong) FlexTouchView *touchClearAppointDriver; //清除指定司机按钮

//迭代去掉 21-08-13
//@property (strong, nonatomic) CJTextField *fieldOpenInvoiceType;  // 开票方式
//@property (nonatomic,copy) NSString *strOpenInvoiceType;  //开票方式名称：0-现付开票，1-到付开票，2-代付开票 ,
// 运输方式  0-干线运输，1-同城配送，2-集装箱
@property (nonatomic,strong) CJTextField *fieldTransportType;  //运输方式
@property (nonatomic,copy) NSString *strTransportType;

@property (nonatomic,strong) CJTextField *fieldTranRequirement; //运输要求

@property (strong, nonatomic) CJTextField *fieldHighestPrice;
@property (strong, nonatomic) CJLabel *labHighestPriceUnit;  //最高价单位
@property (nonatomic,strong) UIView *viewHighestPrice;
@property (nonatomic,strong) CJView *viewOthers;
@property (nonatomic,strong) CJView *viewOthersLine;
@property (nonatomic,strong) CJLabel *attrLabel;


@property (nonatomic,strong) UISwitch *switchCommonSource;
@property (nonatomic,strong) UISwitch *switchIsAllowPrice; // 是否允许报价
@property (nonatomic,copy) NSString *strIsQuote; //0-不允许，1-允许 ,

@property (nonatomic,copy) NSString *strViewOthersIsHidden; // 0否 1 是
@property (nonatomic,strong) CJImageView *imgVOther; //其他页面的小他图标

// 协议
@property (nonatomic,strong) CJImageView *imgVAgree;
@property (nonatomic,copy) NSString *strIsAgree; // 0 1

@property (nonatomic,copy) NSString *strIsOftenOrder; // 是否常发货源 是否常发货源 0->否，1->是
@property (nonatomic,strong) CJLabel *labSaveTitle;
@property (nonatomic,strong) DefaultSettingModel *defaultSettingModel;

@property (nonatomic,copy) NSString *strIsTeam; //指定司机来源:0-司机，1-承运分组 ,;

////临时写固定值
// [dicData setValue:@"777" forKey:@"upstreamCode"]; //上游客户编码
// [dicData setValue:@"90900009" forKey:@"inFee"]; // 上游客户应付

@property (nonatomic,strong) CJTextField *fieldUpstreamName;
@property (nonatomic,copy)  NSString *strUpstreamCode;
@property (nonatomic,strong) CJTextField *fieldUpstreamInFee;
@property (nonatomic,strong) UpstreamCustomerModel *upstreamCustomerModel;
@property (nonatomic,strong) UIView *viewUpstream;
@property (nonatomic,strong) UIView *viewUpstreamInFee;

//@property (strong, nonatomic) CJTextField *fieldUpstreamCustom; // 上游客户
//@property (strong, nonatomic) CJTextField *fieldShoudCollectMoney; //应收
@property (nonatomic,strong) UIView *viewHighestSuper;
@property (nonatomic,copy) NSString *strDistacne;
@property (nonatomic,strong) CJTextField *zhuanghuoAddressTextField;
@property (nonatomic,strong) CJTextField *xiehuoAddressTextField;


//private String industryCode; //货物所属行业code
//
//private String industryName;//货物所属行业名称
//
//private String industryList;//货物所属行业
@property (nonatomic,copy) NSString *strIndustryCode;
@property (nonatomic,copy) NSString *strIndustryName;
@property (nonatomic,copy) NSString *strindustryList;


//装卸货经纬度
@property (nonatomic,copy) NSString *strShipperLongitude; //经度
@property (nonatomic,copy) NSString *strShipperLatitude;
@property (nonatomic,copy) NSString *strConsigneeLongitude;
@property (nonatomic,copy) NSString *strConsigneeLatitude;
//二维码弹框
@property (nonatomic, strong) UIView* bgView;

@property (nonatomic, strong) UIView* erwmView;

@property (nonatomic, strong) UIImageView *erwmImagView;

@property (nonatomic, strong) UILabel *infroLabel;

@property (nonatomic, strong) UILabel *zhAddLabel;

@property (nonatomic, strong) UILabel *zhDetileAddLabel;

@property (nonatomic, strong) UILabel *xhAddLabel;

@property (nonatomic, strong) UILabel *xhDetileAddLabel;

@property (nonatomic, strong) UILabel *zhStateTime;

@property (nonatomic, strong) UILabel *xhEndTime;
@property (nonatomic, strong) UITapGestureRecognizer *changeVoidceSet;

@property (nonatomic, strong) UIButton *buttonImag;
@property (nonatomic, strong) NSMutableArray *titAddArr;

@property (nonatomic,strong) FlexTouchView *generalOrderView;
@property (nonatomic,strong) CJLabel *labgeneralOrderView;
@property (nonatomic,strong) FlexTouchView *baddingOrderView;
@property (nonatomic,strong) CJLabel *labbaddingOrderView;
@property (nonatomic,strong) FlexTouchView *assignmentOrderView;
@property (nonatomic,strong) CJLabel *labassignmentOrderView;
@property (nonatomic,strong) FlexTouchView *menuOrderView;//固定项目单
@property (nonatomic,strong) CJLabel *mentOrderLabel;
@property (nonatomic, strong) UIView *topBottomView;

@property (strong, nonatomic) CJTextField *isAdvanceFreight; //预付运费
@property (strong, nonatomic) CJTextField *isReturnPayMent; //回单打款
@property (strong, nonatomic) CJTextField *isMotorcade; //是否必须加入车队
@property (strong, nonatomic) CJLabel *isMotorcadeTitle;//是否加入车队title
@property (strong, nonatomic) CJLabel *isAdvanceFreightTitle;
@property (nonatomic,strong) FlexTouchView *isAdvanceFreightView;//预付运费
@property (strong, nonatomic) CJLabel *isAdvanceFreightNumber;
@property (nonatomic,strong) FlexTouchView *isReturnPayMentView;//回单比例
@property (strong, nonatomic) CJLabel *isReturnPayIsSelecte;
@property (strong, nonatomic) CJLabel *isReturnPayMentNumber;

@property (strong, nonatomic) NSString *isVehicleTeam;
@property (strong, nonatomic) NSString *prepayScale;
@property (strong, nonatomic) NSString *isPrepay;
@property (strong, nonatomic) NSString *isReceiptPay;
@property (strong, nonatomic) NSString *receiptPayScale;

@property (strong, nonatomic) NSString *staffCode;//结算员工
@property (strong, nonatomic) NSString *staffName;
@property (strong, nonatomic) NSString *settlementType;//结算类型
@property (nonatomic, strong) CJLabel *electronicFenceLabel;//电子围栏范围
@property (nonatomic, strong) CJLabel *taxFundLabel; //税源地
@property (nonatomic, strong) NSString *taxFundcode; //税源地code

@end

@implementation SendGoodsVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
//
//    if (self.strIsChangeOrder.intValue == 1) {
//         [self setTitleName:@"修改订单"];
//    }else if (self.strIsAgainOrder.intValue == 1){
//         [self setTitleName:@"再次下单"];
//    }else{
//        [self setTitleName:@"发布货源"];
//
//    }
    [self setBackLeftButton:@""];
    [self setRightImage:CJLString(@"默认设置") image:@""];

//    [self setSecondAppNavigationBarStyle];
    self.sendGoodsCell = [[SendGoodsCell alloc]initWithFlex:nil reuseIdentifier:nil];
    [self createSendsGoodsVCTopView];
    [self.view addSubview:self.tableView];
    [self createTableView];
    [self setFieldLimit];
    [self setDefaultValue];
    
    if (self.strIsChangeOrder.intValue == 1 || self.strIsAgainOrder.intValue == 1) {
        [self setChangeOrderValue];
    }else{
        [self loadOrederDefaultACtion];
    }
    
    if (self.strIsChangeOrder.intValue == 1) {
        [self setTitleName:@"修改订单"];
        self.labSaveTitle.text = @"修改订单";
    }else if (self.strIsAgainOrder.intValue == 1){
        [self setTitleName:@"再次下单"];
        self.labSaveTitle.text = @"再次下单";
    }else{
        [self setTitleName:@"发布货源"];
        self.labSaveTitle.text = @"下单";
    }
    
    self.generalOrderView.backgroundColor = [UIColor cjWhiteColor];
    self.labgeneralOrderView.textColor = [UIColor cjMainColor];
    self.baddingOrderView.backgroundColor = [UIColor cjWhiteColor];
    self.labbaddingOrderView.textColor = [UIColor cjMainColor];
    self.assignmentOrderView.backgroundColor = [UIColor cjMainColor];
    self.labassignmentOrderView.textColor = [UIColor cjWhiteColor];
    self.menuOrderView.backgroundColor = [UIColor cjWhiteColor];
    self.mentOrderLabel.textColor = [UIColor cjMainColor];
    self.strViewOthersIsHidden = @"0";
    [self btnOtherViewHiddenOrNotAction];
    self.topBottomView.hidden = YES;
    self.strIsQuote = @"0";
    self.switchIsAllowPrice.on = NO;
    self.viewHighestPrice.hidden = YES;
}
- (void)generalOrderViewAction{
    self.generalOrderView.backgroundColor = [UIColor cjMainColor];
    self.labgeneralOrderView.textColor = [UIColor cjWhiteColor];
    self.baddingOrderView.backgroundColor = [UIColor cjWhiteColor];
    self.labbaddingOrderView.textColor = [UIColor cjMainColor];
    self.assignmentOrderView.backgroundColor = [UIColor cjWhiteColor];
    self.labassignmentOrderView.textColor = [UIColor cjMainColor];
    self.menuOrderView.backgroundColor = [UIColor cjWhiteColor];
    self.mentOrderLabel.textColor = [UIColor cjMainColor];
    self.strViewOthersIsHidden = @"1";
    [self btnOtherViewHiddenOrNotAction];
    self.topBottomView.hidden = YES;
    self.strIsQuote = @"0";
    self.switchIsAllowPrice.on = NO;
    self.viewHighestPrice.hidden = YES;
}
//竞价单
- (void)baddingOrderViewAction{
    self.generalOrderView.backgroundColor = [UIColor cjWhiteColor];
    self.labgeneralOrderView.textColor = [UIColor cjMainColor];
    self.baddingOrderView.backgroundColor = [UIColor cjMainColor];
    self.labbaddingOrderView.textColor = [UIColor cjWhiteColor];
    self.assignmentOrderView.backgroundColor = [UIColor cjWhiteColor];
    self.labassignmentOrderView.textColor = [UIColor cjMainColor];
    self.menuOrderView.backgroundColor = [UIColor cjWhiteColor];
    self.mentOrderLabel.textColor = [UIColor cjMainColor];
    self.strViewOthersIsHidden = @"1";
    [self btnOtherViewHiddenOrNotAction];
    self.topBottomView.hidden = NO;
    self.strIsQuote = @"1";
    self.switchIsAllowPrice.on = YES;
    self.viewHighestPrice.hidden = NO;
}
//指派单
- (void)assignmentOrderViewAction{
    self.generalOrderView.backgroundColor = [UIColor cjWhiteColor];
    self.labgeneralOrderView.textColor = [UIColor cjMainColor];
    self.baddingOrderView.backgroundColor = [UIColor cjWhiteColor];
    self.labbaddingOrderView.textColor = [UIColor cjMainColor];
    self.assignmentOrderView.backgroundColor = [UIColor cjMainColor];
    self.labassignmentOrderView.textColor = [UIColor cjWhiteColor];
    self.menuOrderView.backgroundColor = [UIColor cjWhiteColor];
    self.mentOrderLabel.textColor = [UIColor cjMainColor];
    self.strViewOthersIsHidden = @"0";
    [self btnOtherViewHiddenOrNotAction];
    self.topBottomView.hidden = YES;
    self.strIsQuote = @"0";
    self.switchIsAllowPrice.on = NO;
    self.viewHighestPrice.hidden = YES;
}
- (void)menuOrderAction{
    self.generalOrderView.backgroundColor = [UIColor cjWhiteColor];
    self.labgeneralOrderView.textColor = [UIColor cjMainColor];
    self.baddingOrderView.backgroundColor = [UIColor cjWhiteColor];
    self.labbaddingOrderView.textColor = [UIColor cjMainColor];
    self.assignmentOrderView.backgroundColor = [UIColor cjWhiteColor];
    self.labassignmentOrderView.textColor = [UIColor cjMainColor];
    self.menuOrderView.backgroundColor = [UIColor cjMainColor];
    self.mentOrderLabel.textColor = [UIColor cjWhiteColor];
    self.strViewOthersIsHidden = @"1";
    [self btnOtherViewHiddenOrNotAction];
    self.topBottomView.hidden = YES;
    self.strIsQuote = @"3";
    self.switchIsAllowPrice.on = NO;
    self.viewHighestPrice.hidden = YES;
}
- (void)RightTextClick:(UIButton *)sender{
    WS(ws);
    DefaultSettingVC *vc = [DefaultSettingVC new];
    vc.blockSuccess = ^(id anyObject) {
        [ws loadOrederDefaultACtion];

    };
    [self pushVc:vc];
}
- (void)loadOrederDefaultACtion{
    
    NSString *strURL = CJStringWithFormat(@"%@/ntocc-tms-api/orderDefaultInfo/default",CJBaseUrl);

    NSDictionary *dic = [[NSDictionary alloc]init];
    WS(ws);
    [[HDNetworking sharedHDNetworking] GET:strURL parameters:dic success:^(id  _Nonnull responseObject) {
        
        DLog(@"++++++++%@",responseObject);
        NSDictionary *dic = (NSDictionary *)responseObject;
        if (dic.count == 0) {
           
        }else{
            NSError *error;
            self.defaultSettingModel = [[DefaultSettingModel alloc] initWithDictionary:dic error:nil];
            [ws refreshData];
        }

    } failure:^(NSError * _Nonnull error) {
        DLog(@"++++++++%@",error);
        
    }];

}

- (void)refreshData{
//    self.dicGoodsName = [[NSDictionary alloc]init];
//    self.dicUserCarType = [[NSDictionary alloc]init];
    // 名称
//    WS(ws);
//    NSArray *list = self.defaultSettingModel.coalTypeList;
//
//    if (list.count > 0) {
//        [list enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
//            NSArray *listCode = (NSArray *)obj;
//            if (idx == 0) {
//                ws.strGoodsNameCodes = listCode[0];
//            }else{
//                ws.strGoodsNameCodes = CJStringWithFormat(@"%@,%@",ws.strGoodsNameCodes,listCode[0]);
//            }
//        }];
//    }else{
//        self.strGoodsNameCodes = @"0";
//    }
    
    
    self.strGoodsNameCodes = self.defaultSettingModel.coalType;
    self.fieldGoodsName.text = self.defaultSettingModel.coalTypeName;
    self.settlementType = self.sourceListModel.settlementType;
    if ([self.sourceListModel.settlementType intValue] == 0 && ![CJRegular getIsStrEmpty:self.sourceListModel.settlementType]) {
        self.selectedDriverTextField.text = @"按装货数量";
    }else if ([self.sourceListModel.settlementType intValue] == 1){
        self.selectedDriverTextField.text = @"按卸货数量";
    }else if([self.sourceListModel.settlementType intValue] == 2){
        self.selectedDriverTextField.text = @"按装卸货数量最小值";
    }else{
        self.selectedDriverTextField.text = @"";
    }
//    self.staffName = self.sourceListModel.staffName;
//    self.staffCode = self.sourceListModel.staffCode;
    self.strGoodsBigTypeCode = self.defaultSettingModel.coalBigType;
    self.strGoodsBigTypeName = self.defaultSettingModel.coalBigTypeName;
    
    
    self.fieldGoodsNum.text = @(self.defaultSettingModel.weight).cj_description;
    self.strGoodsTransferFeeUnits  = self.defaultSettingModel.coalUnit;
    self.labGoodsTransferFeeUnits.text = self.defaultSettingModel.coalUnitName;
    
    if ([self.defaultSettingModel.coalUnit intValue] == 2) {
        [self setFieldGoodsNumThreeDecimalPlace:NO];
    }else{
        [self setFieldGoodsNumThreeDecimalPlace:YES];
    }
    
    
    self.fieldGoodsPrice.text = @(self.defaultSettingModel.coalPrice).cj_money_description;
    
    self.labGoodsPriceUnit.text = CJStringWithFormat(@"元/%@",self.defaultSettingModel.coalUnitName);
    self.strLossCode = CJStringWithFormat(@"%ld",(long)self.defaultSettingModel.limitWastageType); // 损耗 默认1 kg/che
    if ([[self.strLossCode substringFromIndex:0] isEqualToString:@"0"]) {
        self.fleidLoss.enabled = NO;
        self.fleidLoss.backgroundColor = [UIColor cjBackgroundColor];
        
    }else{
        self.fleidLoss.enabled = YES;
        self.fleidLoss.backgroundColor = [UIColor cjWhiteColor];
    }
    
    
    if (self.defaultSettingModel.isTrunk == 3) {
        self.fleidLoss.text = @"0";
        self.labLossUnit.text = @"不计";
        self.fleidLoss.enabled = NO;
        self.fleidLoss.backgroundColor = [UIColor cjBackgroundColor];
//        self.touchViewLoss.userInteractionEnabled = NO;
    }else{
//        self.touchViewLoss.userInteractionEnabled = YES;

    }
    
    
    self.fleidLoss.text = CJStringWithFormat(@"%@",self.defaultSettingModel.limitWastageAmount);
    self.labLossUnit.text = self.defaultSettingModel.limitWastageTypeName;
    self.strFreightCostUnit = CJStringWithFormat(@"%ld",(long)self.defaultSettingModel.isTrunk);
    self.labFreightCostUnit.text = self.defaultSettingModel.isTrunkName;
    self.fieldFreightCost.text = @(self.defaultSettingModel.price).cj_money_description;
    
    if (self.defaultSettingModel.isInsure == 1) {
        self.strIsInsure = @"1"; //投保类别：0-不投保
        self.switchInSure.on = YES;
        self.viewInSureMoney.hidden = NO;
        self.strInSureMoneyCode =  CJStringWithFormat(@"%@",self.defaultSettingModel.insuranceCode);
        self.fieldInSureMoney.text = self.defaultSettingModel.insuranceFeeName;
    }else if(self.defaultSettingModel.isInsure == 0){
        self.strIsInsure = @"0"; //投保类别：0-不投保
        self.switchInSure.on = NO;
        self.viewInSureMoney.hidden = YES;
        self.strInSureMoneyCode =  @"";
       
        self.fieldInSureMoney.text = @"";
        
    }
    
    self.strAppointDriverCode = self.defaultSettingModel.pushTarget; // 指定司机
//    self.fieldAppointDriver.text = self.model.pushTargetName;
    self.fieldUserCarType.text = self.defaultSettingModel.pushVehicleUse;
    
//    迭代去掉 21-08-13
//    self.strOpenInvoiceType  =  CJStringWithFormat(@"%ld",(long)self.defaultSettingModel.billingType);
//    self.fieldOpenInvoiceType.text = self.defaultSettingModel.billingTypeName;
    self.fieldTranRequirement.text = self.defaultSettingModel.coalName;
    
    if (self.defaultSettingModel.isQuote == 0) {
        self.strIsQuote = @"0";
        self.switchIsAllowPrice.on = NO;
        self.fieldHighestPrice.text  = @"";
    }else if(self.defaultSettingModel.isQuote == 1){
        self.strIsQuote = @"1";
        self.switchIsAllowPrice.on = YES;
        self.fieldHighestPrice.text  =  @(self.defaultSettingModel.maxPrice).cj_money_description;
    }
    
    [header layoutIfNeeded];
    [self.tableView reloadData];

}

- (void)setDefaultValue{
    

    self.strIndustryCode = @"";
    self.strIndustryName = @"";
    self.strindustryList = @"";

//    self.strViewOthersIsHidden = @"1";
//    self.strIsSetDefault = @"0";
    self.strIsAgree = @"1";
    self.strDistacne = @"";
//    self.imgVAgree.image = [UIImage imageNamed:@"selected"];
//
//    self.dicGoodsName = [[NSDictionary alloc]init];
//    self.strGoodsNameCodes = @"";
//    self.strGoodsSmallName = @"";
//    self.strGoodsBigTypeCode = @"";
//    self.strGoodsBigTypeName = @"";
//    self.strGoodsTransferFeeUnits = @"1" ;// 默认吨
//    self.strLossCode = @"1"; // 损耗 默认1 kg/che
//    self.strFreightCostUnit = @"1"; // 默认元/吨 运费单价
//    self.strIsInsure = @"0";
//    self.strInSureMoneyCode = @"";
//    self.strAppointDriverCode = @"";
//    self.strOpenInvoiceType = @"";
//    self.strIsQuote = @"0";
////    self.viewHighestPrice.hidden = YES;
//
//    self.strIsOftenOrder = @"0";
//    self.dicUserCarType = [[NSDictionary alloc] init];
//
//    self.fieldOpenInvoiceType.text = @"现付开票";
//    self.strOpenInvoiceType = @"0";
    
    self.fieldGoodsNum.delegate = self;
    self.fieldGoodsPrice.delegate = self;
    
    self.viewAdress.hidden = YES;
    self.labUploadAdress.text = @"";
    self.labDownloadAdress.text = @"";
    self.labDownloadName.text = @"";
    self.labDownloadPhone.text = @"";
    self.labUploadPhone.text = @"";
    self.labUploadName.text = @"";
    self.strDownloadCountyCode  = @""; //收货国家行政区划代码
    self.strDownloadAdress = @"";
    self.strUploadAdress = @"";
    self.strUploadCountyCode = @"";
    
    self.strGoodsBigTypeCode  = @""; //货物名称编码（大类）
    self.strGoodsBigTypeName = @"";
    self.strGoodsNameCodes = @"0";//货物名称名称（小类）
    self.fieldGoodsName.text = @"";
    self.selectedDriverTextField.text = @"";//选择员工
    self.fieldGoodsNum.text = @"";// 货物数量

    self.strGoodsTransferFeeUnits  = @"0";
    self.labGoodsTransferFeeUnits.text = @"吨";//货物单位 0：吨 1：立方米，2-件 ,
    
    self.fieldGoodsPrice.text = @""; //货物价值单价
    self.labGoodsPriceUnit.text = @"元/吨";
    self.electronicFenceLabel.text = @"不限";
    self.taxFundLabel.text = @"";
    self.taxFundcode = @"";
    self.strLossCode = @"0"; //
    self.fleidLoss.enabled = NO;
    self.fleidLoss.backgroundColor = [UIColor cjBackgroundColor];
    self.fleidLoss.text = @"0";
    self.labLossUnit.text = @"不计";
 
    //货物运费单位：0-元/吨，1-元/方，2-元/件，3-元/车
    self.strFreightCostUnit = @"0";
    self.labFreightCostUnit.text = @"元/吨";
    self.fieldFreightCost.text = @""; //成交单价--非含税价--司机单价 ,
    
    self.fieldCarNumsRequir.text = @"";//// 需求车数 ,
    self.fieldUpLoadGoodsTime.text = @"";////装货截止时间
    self.fieldDomnLoadCoodsTime.text = @"";
    self.zhuanghuoAddressTextField.text = @"";
    self.xiehuoAddressTextField.text = @"";
    self.labDistance.text = @"";
    self.strDistacne = @"";
    self.strIsInsure  = @"0";//投保类别：0-不投保
    self.strInSureMoneyCode = @"";
    self.switchInSure.on = NO;
    self.viewInSureMoney.hidden = YES;

    self.strAppointDriverCode = @"";// 指定司机
    self.fieldAppointDriver.text = @"";//
//    迭代去掉 21-08-13
//    self.strOpenInvoiceType = @"0";//// 开票方式 //开票方式名称：0-现付开票，1-到付开票，2-代付开票 ,
//    self.fieldOpenInvoiceType.text = @"现付开票";
    
    self.fieldTransportType.text = @"干线运输";
    // 运输方式  0-干线运输，1-同城配送，2-集装箱
    self.strTransportType = @"0";
    
    self.strIsOftenOrder = @"0";
    self.switchIsAllowPrice.on = NO;

    self.fieldTranRequirement.text  = @"";//  运输要求
    

    self.switchIsAllowPrice.on = NO;
    self.strIsQuote = @"0";

    
    self.fieldHighestPrice.text = @"";
    self.labHighestPriceUnit.text = @"元/吨";
//    self.strInSureMoneyCode = @"";
    self.fieldInSureMoney.text = @"";
    self.fieldUserCarType.text = @"";
    self.strIsTeam = @""; //指定司机来源:0-司机，1-承运分组 ,;
    self.fieldUpstreamName.text = @"";
    self.fieldUpstreamInFee.text = @"";
    self.strUpstreamCode = @"";
    
    if ([CJControl getIsCompany]) {
        self.viewUpstream.hidden = NO;
    }else{
        self.viewUpstream.hidden = YES;

    }
    
//    装卸货经纬度
    self.strShipperLongitude = @"";
    self.strShipperLatitude = @"";
    self.strConsigneeLongitude = @"";
    self.strConsigneeLatitude = @"";

    self.isVehicleTeam = @"否";
    self.isPrepay = @"否";
    self.isReceiptPay = @"否";
    self.prepayScale = @"0";
    self.receiptPayScale = @"0";
    self.isAdvanceFreightView.hidden = YES;
    self.isReturnPayMentView.hidden = YES;
    [header layoutIfNeeded];
    [self.tableView reloadData];
}


- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
        
    if ([CJRegular getIsStrEmpty:self.strAppointDriverCode]) {
        self.touchClearAppointDriver.hidden = YES;
    }else{
        self.touchClearAppointDriver.hidden = NO;
    }
    
    if (self.sourceListModel.pushTargetChange == 1) {
        self.labAppointDriverWran.hidden = NO;
    }else{
        self.labAppointDriverWran.hidden = YES;
    }
    
    
}
- (void)setChangeOrderValue{
    
    DLog(@"====== %@",self.sourceListModel);
    self.viewAdress.hidden = NO;
    
    self.labUploadAdress.text = CJStringWithFormat(@"%@%@",self.sourceListModel.shipperAddress,self.sourceListModel.shipperDetailAddress);
    self.labDownloadAdress.text = CJStringWithFormat(@"%@%@",self.sourceListModel.consigneeAddress,self.sourceListModel.consigneeDetailAddress);
    // 详细地址   strUploadDetailAdress  strDownloadDetailAdress
    self.strDownloadDetailAdress = self.sourceListModel.consigneeDetailAddress;
    self.strUploadDetailAdress = self.sourceListModel.shipperDetailAddress;
    
    self.labDownloadName.text = self.sourceListModel.consigneeName;
    self.electronicFenceLabel.text = self.sourceListModel.addressFence;
    if (self.sourceListModel.taxLocationCode) {
        NSDictionary *dic = CJFetchMyDefault(CJPartyUserCenter);
        NSArray *currentArr = dic[@"taxMultipleSources"];
        for (NSDictionary *dic in currentArr) {
            if ([dic[@"code"] isEqualToString:self.sourceListModel.taxLocationCode]) {
            self.taxFundLabel.text = dic[@"taxName"];
            self.taxFundcode = dic[@"code"];
            }
        }
    }
    
    self.labDownloadPhone.text = self.sourceListModel.consigneePhone;
    self.labUploadPhone.text = self.sourceListModel.shipperPhone;
    self.labUploadName.text = self.sourceListModel.shipperName;
    self.strDownloadCountyCode  = self.sourceListModel.consigneeSubdivisionCode;
    //
    
    //收货国家行政区划代码
    self.strDownloadAdress = self.sourceListModel.consigneeAddress;
    self.strUploadAdress = self.sourceListModel.shipperAddress;
    self.strUploadCountyCode = self.sourceListModel.shipperSubdivisionCode;
    
    self.strGoodsBigTypeCode  = self.sourceListModel.coalBigType; //货物名称编码（大类）
    self.strGoodsBigTypeName = self.sourceListModel.coalBigTypeName;
    self.strGoodsNameCodes = self.sourceListModel.coalType;//货物名称名称（小类）
    self.fieldGoodsName.text = self.sourceListModel.coalTypeName;
//    self.selectedDriverTextField.text = self.sourceListModel.staffName;
//    self.staffName = self.sourceListModel.staffName;
//    self.staffCode = self.sourceListModel.staffCode;
    self.settlementType = self.sourceListModel.settlementType;
    if ([self.sourceListModel.settlementType intValue] == 0 && ![CJRegular getIsStrEmpty:self.sourceListModel.settlementType]) {
        self.selectedDriverTextField.text = @"按装货数量";
    }else if ([self.sourceListModel.settlementType intValue] == 1){
        self.selectedDriverTextField.text = @"按卸货数量";
    }else if([self.sourceListModel.settlementType intValue] == 2){
        self.selectedDriverTextField.text = @"按装卸货数量最小值";
    }else{
        self.selectedDriverTextField.text = @"";
    }
    self.fieldGoodsNum.text = @(self.sourceListModel.weight).cj_description;// 货物数量
    self.strGoodsTransferFeeUnits = self.sourceListModel.coalUnit;
    self.labGoodsTransferFeeUnits.text = self.sourceListModel.coalUnitName;//货物单位 0：吨 1：立方米，2-件 ,
    
    if ([self.sourceListModel.coalUnit isEqualToString:@"2"]) {
        [self setFieldGoodsNumThreeDecimalPlace:NO];
    }else{
        [self setFieldGoodsNumThreeDecimalPlace:YES];
    }
    

     
    self.fieldGoodsPrice.text = @(self.sourceListModel.coalPrice).cj_money_description; //货物价值单价
    self.labGoodsPriceUnit.text = CJStringWithFormat(@"元/%@",self.sourceListModel.coalUnitName);
    self.fleidLoss.text  = CJStringWithFormat(@"%@",@(self.sourceListModel.limitWastageAmount).cj_description); //货物损耗数量 /kg
    self.labLossUnit.text = self.sourceListModel.limitWastageTypeName; //货物损耗数量 /kg
    self.strLossCode  = CJStringWithFormat(@"%ld",self.sourceListModel.limitWastageType);////
    
    if ([[self.strLossCode substringFromIndex:0] isEqualToString:@"0"]) {
        self.fleidLoss.enabled = NO;
        self.fleidLoss.backgroundColor = [UIColor cjBackgroundColor];
        self.labLossUnit.text = @"不计";
    }else{
        self.fleidLoss.enabled = YES;
        self.fleidLoss.backgroundColor = [UIColor cjWhiteColor];
    }
   
    // 运费单价 元/车  合理损耗默认不计 
//    if (self.sourceListModel.isTrunk == 3) {
//        self.fleidLoss.text = @"0";
//        self.labLossUnit.text = @"不计";
//        self.fleidLoss.enabled = NO;
//        self.fleidLoss.backgroundColor = [UIColor cjBackgroundColor];
////        self.touchViewLoss.userInteractionEnabled = NO;
//    }else{
////        self.touchViewLoss.userInteractionEnabled = YES;
//
//    }
    
    //货物运费单位：0-元/吨，1-元/方，2-元/件，3-元/车
    self.strFreightCostUnit = CJStringWithFormat(@"%ld",self.sourceListModel.isTrunk);
    self.labFreightCostUnit.text = self.sourceListModel.isTrunkName;
    self.fieldFreightCost.text = @(self.sourceListModel.price).cj_money_description; //成交单价--非含税价--司机单价 ,
    
    self.fieldCarNumsRequir.text = CJStringWithFormat(@"%ld",self.sourceListModel.coalNumber);//// 需求车数 ,
    self.fieldUpLoadGoodsTime.text = self.sourceListModel.lastLoadingTime;////装货截止时间
    self.fieldDomnLoadCoodsTime.text = self.sourceListModel.lastUnloadingTime;
    self.zhuanghuoAddressTextField.text = self.sourceListModel.addressProfile;
    self.xiehuoAddressTextField.text = self.sourceListModel.addressFill;
    self.labDistance.text = CJStringWithFormat(@"%@公里",@(self.sourceListModel.distance).cj_description);
    self.strDistacne = CJStringWithFormat(@"%@",@(self.sourceListModel.distance).cj_description);
    self.strIsInsure  = CJStringWithFormat(@"%ld",self.sourceListModel.isInsure) ;//投保类别：0-不投保
    
    if (self.sourceListModel.isInsure == 1) {
        self.switchInSure.on = YES;
        self.viewInSureMoney.hidden = NO;
        
    }else{
        self.switchInSure.on = NO;
        self.viewInSureMoney.hidden = YES;
        self.strInSureMoneyCode = @"";
    }
    
    self.strAppointDriverCode = self.sourceListModel.pushTarget;// 指定司机
    self.fieldAppointDriver.text = self.sourceListModel.pushTargetName;//
//    迭代去掉 21-08-13
//    self.strOpenInvoiceType = CJStringWithFormat(@"%ld",self.sourceListModel.billingType);//// 开票方式
//    self.fieldOpenInvoiceType.text = self.sourceListModel.billingTypeName;

    // 运输方式
    self.fieldTransportType.text = self.sourceListModel.transportTypeName;
    self.strTransportType = self.sourceListModel.transportType;
    
//    屏蔽掉 ，再次下单等 不对是否常发货源 赋值
//    self.strIsOftenOrder = CJStringWithFormat(@"%ld",self.sourceListModel.isOftenOrder);
//    if (self.sourceListModel.isOftenOrder == 1) {
////        self.strIsOftenOrder = @"1";
//        self.switchIsAllowPrice.on = YES;
//    }else{
////        self.strIsOftenOrder = @"";
//        self.switchIsAllowPrice.on = NO;
//
//    }
    
    self.fieldTranRequirement.text  = self.sourceListModel.coalName;//  运输要求
    
    // 是否允许报价
    if (self.sourceListModel.isQuote == 1) {
        self.switchIsAllowPrice.on = YES;
        self.strIsQuote = @"1";
        self.viewHighestPrice.hidden = NO;
    }else{
        self.switchIsAllowPrice.on = NO;
        self.strIsQuote = @"0";
        self.viewHighestPrice.hidden = YES;
    }
    
    self.fieldHighestPrice.text = @(self.sourceListModel.maxPrice).cj_money_description;
    self.labHighestPriceUnit.text = self.sourceListModel.isTrunkName;
    self.strInSureMoneyCode = CJStringWithFormat(@"%@",self.sourceListModel.insuranceCode);
    self.fieldInSureMoney.text = self.sourceListModel.insuranceFeeName;
    self.fieldUserCarType.text = self.sourceListModel.pushVehicleUse;
    
    self.strIsTeam = CJStringWithFormat(@"%ld",(long)self.sourceListModel.isTeam);
    
    if ([CJControl getIsCompany]) {
        self.strUpstreamCode = self.sourceListModel.upstreamCode;
        self.fieldUpstreamInFee.text = @(self.sourceListModel.inFee).cj_money_description;
        self.fieldUpstreamName.text = self.sourceListModel.upstreamName;
        self.viewUpstream.hidden = NO;
        self.viewUpstreamInFee.hidden = NO;
    }else{

        self.viewUpstream.hidden = YES;
        self.viewUpstreamInFee.hidden = YES;
    }
    
    
    //    //private String industryCode; //货物所属行业code
    //    //
    //    //private String industryName;//货物所属行业名称
    //    //
    //    //private String industryList;//货物所属行业
    //    @property (nonatomic,copy) NSString *strIndustryCode
    
    if ([CJControl getIsTax]) {
        self.strIndustryName = self.sourceListModel.industryName;
        self.fieldIndustryName.text = self.sourceListModel.industryName;
        self.strIndustryCode = self.sourceListModel.industryCode;
        self.strindustryList = self.sourceListModel.industryList;
    }
    
    //    装卸货经纬度
    self.strShipperLongitude = self.sourceListModel.shipperLongitude;
    self.strShipperLatitude = self.sourceListModel.shipperLatitude;
    self.strConsigneeLongitude = self.sourceListModel.consigneeLongitude;
    self.strConsigneeLatitude = self.sourceListModel.consigneeLatitude;
//    车数要求是否非必填
    [self setLabCarNumsRequirAction];
    if([self.sourceListModel.isVehicleTeam isEqualToString:@"1"]){
        self.isMotorcadeTitle.text = @"是";
    }else{
        self.isMotorcadeTitle.text = @"否";
    }
    if([self.sourceListModel.isPrepay isEqualToString:@"1"]){
        self.isAdvanceFreightTitle.text = @"是";
        self.isAdvanceFreightView.hidden = NO;
    }else{
        self.isAdvanceFreightTitle.text = @"否";
        self.isAdvanceFreightView.hidden = YES;
        self.prepayScale = self.sourceListModel.prepayScale;
    }
    if([self.sourceListModel.isReceiptPay isEqualToString:@"1"]){
        self.isReturnPayIsSelecte.text = @"是";
        self.isReturnPayMentView.hidden = NO;
    }else{
        self.isReturnPayIsSelecte.text = @"否";
        self.isReturnPayMentView.hidden = YES;
        self.receiptPayScale = self.sourceListModel.receiptPayScale;
    }
    
    [header layoutIfNeeded];
    [self.tableView reloadData];
    
    [self setOtherViewAction];
    
}


- (void)createSendsGoodsVCTopView{
    
    CGRect rcFrame1 = CGRectMake(0, kTopHeight, [[UIScreen mainScreen] bounds].size.width, 0);
    topView = [[FlexFrameView alloc] initWithFlex:@"SendGoodsTopView" Frame:rcFrame1 Owner:self];
    topView.flexibleHeight = YES;
    [topView layoutIfNeeded];
    [self.view addSubview:topView];
}
/// 创建tableview 等
- (void)createTableView{
    
    //    WS(ws);
    CGRect rcFrame = CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 0);
    header = [[FlexFrameView alloc] initWithFlex:@"SendsGoodsHeaderView" Frame:rcFrame Owner:self];
    header.flexibleHeight = YES;

    if ([CJControl getIsTax]) {
        self.viewIndustry.hidden = NO;
    }else{
        self.viewIndustry.hidden = YES;
    }
    
    [header layoutIfNeeded];
    
    bottomView = [[FlexFrameView alloc] initWithFlex:@"SendGoodBottomView" Frame:rcFrame Owner:self];
    bottomView.flexibleHeight = YES;
    [bottomView layoutIfNeeded];
    
    // 是否投保
    [self.switchInSure addTarget:self action:@selector(switchInSureAction:)forControlEvents:UIControlEventValueChanged | UIControlEventTouchDragExit];
    self.switchInSure.transform = CGAffineTransformMakeScale(0.75, 0.75);
    self.switchInSure.onTintColor = [UIColor cjMainColor];
    
//    switchCommonSource
    // 是否常用货源
    [self.switchCommonSource addTarget:self action:@selector(switchCommonSourceAction:)forControlEvents:UIControlEventValueChanged | UIControlEventTouchDragExit];
    self.switchCommonSource.transform = CGAffineTransformMakeScale(0.75, 0.75);
    self.switchCommonSource.onTintColor = [UIColor cjMainColor];
    
    //是否允许报价
    [self.switchIsAllowPrice addTarget:self action:@selector(switchIsAllowPriceAction:)forControlEvents:UIControlEventValueChanged | UIControlEventTouchDragExit];
    self.switchIsAllowPrice.transform = CGAffineTransformMakeScale(0.75, 0.75);
    self.switchIsAllowPrice.onTintColor = [UIColor cjMainColor];
    
    if ([CJControl getIsCompany]) {
        self.viewUpstream.hidden = NO;
    }
    
    self.tableView.tableHeaderView = header;
    self.tableView.tableFooterView = bottomView;
    [self.tableView reloadData];

}


#pragma mark ----------点击事件----

- (void)btnOCRRecognizeAction{
//    [CJAlert showStringDismissWithDelay:@"OCR识别"];
    [self.view endEditing:NO];
    [self selelctOCRRecognize];
}

- (void)btnSetDeafultValueAction{
    
    if (self.strIsSetDefault.intValue == 0) {
        self.strIsSetDefault = @"1";
        self.imgVSetDefault.image = [UIImage imageNamed:@"selected"];
    }else{
        self.strIsSetDefault = @"0";
        self.imgVSetDefault.image = [UIImage imageNamed:@"zcj_unSelected"];

    }
}

//常用路线
- (void)btnCommonRouteAction{
    
    WS(ws);
    CommonRouteVC *vc = [CommonRouteVC new];
    vc.clickBack = YES;
    vc.blockCommonRoute = ^(id anyObject) {
        
        ws.viewAdress.hidden = NO;
       
        CommonRouteModel *model = (CommonRouteModel *)anyObject;
        ws.labUploadName.text = model.consignorName;
        ws.labUploadPhone.text = model.consignorPhone;
        ws.labUploadAdress.text = CJStringWithFormat(@"%@%@",model.consignorAddress,model.consignorDetailAddress);
        
        ws.strUploadCountyCode = model.consignorCountyCode;
        ws.strUploadDetailAdress =model.consignorDetailAddress;
        ws.strUploadAdress = model.consignorAddress;
        
        ws.labDownloadName.text = model.consigneeName;
        ws.labDownloadPhone.text = model.consigneePhone;
        ws.labDownloadAdress.text = CJStringWithFormat(@"%@%@",model.consigneeAddress,model.consigneeDetailAddress);
//        ws.strUploadDetailAdress = model.consigneeDetailAddress;
        ws.strDownloadDetailAdress = model.consigneeDetailAddress;
        ws.strDownloadAdress = model.consigneeAddress;
        ws.strDownloadCountyCode = model.consigneeCountyCode;
        // 经纬度赋值
        ws.strShipperLatitude = model.shipperLatitude;
        ws.strShipperLongitude = model.shipperLongitude;
        ws.strConsigneeLatitude = model.consigneeLatitude;
        ws.strConsigneeLongitude = model.consigneeLongitude;
        
        NSDictionary *dic = @{
            @"shipperAddress":CJStringWithFormat(@"%@%@",model.consignorAddress,model.consignorDetailAddress),
            @"consigneeAddress":CJStringWithFormat(@"%@%@",model.consigneeAddress,model.consigneeDetailAddress)
        };
        
        NSDictionary *dictLatLong = @{
         @"shipperGrid":CJStringWithFormat(@"%@,%@",ws.strShipperLongitude,ws.strShipperLatitude),
         @"consigneeGrid":CJStringWithFormat(@"%@,%@",ws.strConsigneeLongitude,ws.strConsigneeLatitude)
        };
        
        if ([CJControl getSelectAdressByAmap]) {
            [ws getCommonRouteDistanceByLatLong:dictLatLong];
        }else{
            [ws getCommonRouteDistance:dic];

        }
        
        [header layoutIfNeeded];
        [ws.tableView reloadData];
        [ws selectHighlightOrNotwitnIndex:0];
         [ws setOtherViewAction];
    };
    
    [self pushVc:vc];
}

- (void)getCommonRouteDistance:(NSDictionary *)dic{
    WS(ws);
    [CJNetWork getCommonRouteDistance:dic Success:^(id  _Nullable responseObject) {
        
        NSString *str = responseObject[@"distance"];
        ws.strDistacne = CJStringWithFormat(@"%@",@([str floatValue]/1000).cj_description);
        ws.labDistance.text = CJStringWithFormat(@"%@公里",@([ws.strDistacne floatValue]).cj_description);
    }];
}
- (void)getCommonRouteDistanceByLatLong:(NSDictionary *)dic{
    WS(ws);
    [CJNetWork getCommonRouteDistanceByLatLong:dic Success:^(id  _Nullable responseObject) {
        
        NSString *str = responseObject[@"distance"];
        ws.strDistacne = CJStringWithFormat(@"%@",@([str floatValue]/1000).cj_description);
        ws.labDistance.text =  CJStringWithFormat(@"%@公里",@([str floatValue]/1000).cj_description);//CJStringWithFormat(@"%0.2f公里",[ws.strDistacne floatValue]/1);
    }];
}

- (void)btnAddNewRouteAction{

    WS(ws);
    AddNewCommonRouteVC *vc = [[AddNewCommonRouteVC alloc]init];
    vc.isSendGoods = YES;
    vc.strTitle = @"新增路线";
    vc.blockSendGoods = ^(id anyObject) {
        NSDictionary *dic = (NSDictionary *)anyObject;
        
        ws.viewAdress.hidden = NO;
      
        ws.labUploadName.text = dic[@"consignorName"];
        ws.labUploadPhone.text = dic[@"consignorPhone"];
        ws.labUploadAdress.text = CJStringWithFormat(@"%@%@",dic[@"consignorAddress"],dic[@"consignorDetailAddress"]);
        ws.strUploadCountyCode = dic[@"consignorCountyCode"];
        ws.strUploadDetailAdress =  dic[@"consignorDetailAddress"];
        ws.strUploadAdress = dic[@"consignorAddress"];

        ws.labDownloadName.text = dic[@"consigneeName"];
        ws.labDownloadPhone.text = dic[@"consigneePhone"];
        ws.labDownloadAdress.text =  CJStringWithFormat(@"%@%@",dic[@"consigneeAddress"],dic[@"consigneeDetailAddress"]);
//        ws.strUploadDetailAdress =  dic[@"consigneeDetailAddress"];
        ws.strDownloadDetailAdress = dic[@"consigneeDetailAddress"];
        ws.strDownloadAdress =  dic[@"consigneeAddress"];
        ws.strDownloadCountyCode =  dic[@"consigneeCountyCode"];
        ws.strShipperLongitude = [CJControl getThreeUnaryValueStr:dic[@"shipperLongitude"]];
        ws.strShipperLatitude = [CJControl getThreeUnaryValueStr:dic[@"shipperLatitude"]];
        ws.strConsigneeLongitude = [CJControl getThreeUnaryValueStr:dic[@"consigneeLongitude"]];
        ws.strConsigneeLatitude = [CJControl getThreeUnaryValueStr:dic[@"consigneeLatitude"]];
        NSDictionary *dict = @{
         @"shipperAddress":CJStringWithFormat(@"%@%@",dic[@"consignorAddress"],dic[@"consignorDetailAddress"]),
         @"consigneeAddress":CJStringWithFormat(@"%@%@",dic[@"consigneeAddress"],dic[@"consigneeDetailAddress"])
        };
        
        NSDictionary *dictLatLong = @{
         @"shipperGrid":CJStringWithFormat(@"%@,%@",ws.strShipperLongitude,ws.strShipperLatitude),
         @"consigneeGrid":CJStringWithFormat(@"%@,%@",ws.strConsigneeLongitude,ws.strConsigneeLatitude)
        };
        
        if ([CJControl getSelectAdressByAmap]) {
            [ws getCommonRouteDistanceByLatLong:dictLatLong];
        }else{
            [ws getCommonRouteDistance:dict];

        }
        
        [header layoutIfNeeded];
        [ws.tableView reloadData];
        [ws selectHighlightOrNotwitnIndex:1];
        [ws setOtherViewAction];
    };
    [self pushVc:vc];
}

/// 修改路线
- (void)btnChangeAddNewRouteAction{
//    [CJAlert showStringDismissWithDelay:@"隐私协议"];
    NSDictionary *dicP = @{
        @"consignorName":[CJControl getThreeUnaryValueStr:self.labUploadName.text],
        @"consignorPhone":[CJControl getThreeUnaryValueStr:self.labUploadPhone.text],
        @"consignorCountyCode":[CJControl getThreeUnaryValueStr:self.strUploadCountyCode],
        @"consignorAddress":[CJControl getThreeUnaryValueStr:self.strUploadAdress],
        @"consignorDetailAddress":[CJControl getThreeUnaryValueStr:self.strUploadDetailAdress],
//
        @"consigneeName":[CJControl getThreeUnaryValueStr:self.labDownloadName.text],
        @"consigneePhone":[CJControl getThreeUnaryValueStr:self.labDownloadPhone.text],
        @"consigneeCountyCode":[CJControl getThreeUnaryValueStr:self.strDownloadCountyCode],
        @"consigneeAddress":[CJControl getThreeUnaryValueStr:self.strDownloadAdress],
        @"consigneeDetailAddress":[CJControl getThreeUnaryValueStr:self.strDownloadDetailAdress],
        @"shipperLongitude":[CJControl getThreeUnaryValueStr:self.strShipperLongitude],
        @"shipperLatitude":[CJControl getThreeUnaryValueStr:self.strShipperLatitude],
        @"consigneeLongitude":[CJControl getThreeUnaryValueStr:self.strConsigneeLongitude],
        @"consigneeLatitude":[CJControl getThreeUnaryValueStr:self.strConsigneeLatitude]
    };
    
    WS(ws);
    AddNewCommonRouteVC *vc = [[AddNewCommonRouteVC alloc]init];
    vc.isSendGoods = YES;
    vc.strTitle = @"修改路线";
    vc.isEditorSendGoodsRoute  = YES;
    vc.dicSendGoodsRouteData = dicP;
    vc.isEditorRoute = @"0";
    vc.blockChangeAddNewRoute = ^(id anyObject) {
       
        NSDictionary *dic = (NSDictionary *)anyObject;
        
        ws.viewAdress.hidden = NO;

//        ws.labUploadName.text =
//        ws.labUploadPhone.text = dic[@"consigneePhone"];
//        ws.labUploadAdress.text = dic[@"consigneeName"]; CJStringWithFormat(@"%@%@",dic[@"consigneeAddress"],dic[@"consigneeDetailAddress"]);
//        ws.strUploadCountyCode = dic[@"consigneeCountyCode"];
//        ws.strUploadDetailAdress = dic[@"consigneeDetailAddress"];
//        ws.strUploadAdress = dic[@"consigneeAddress"];
//
//        ws.labDownloadName.text = dic[@"consignorName"];
//        ws.labDownloadPhone.text = dic[@"consignorPhone"];
//        ws.labDownloadAdress.text = CJStringWithFormat(@"%@%@",dic[@"consignorAddress"],dic[@"consignorDetailAddress"]);
////        ws.strUploadDetailAdress = dic[@"consigneeDetailAddress"];
//        ws.strDownloadDetailAdress = dic[@"consignorDetailAddress"];
//        ws.strDownloadAdress = dic[@"consignorAddress"];
//        ws.strDownloadCountyCode = dic[@"consignorCountyCode"];
        
        ws.labUploadName.text = dic[@"consignorName"];
        ws.labUploadPhone.text = dic[@"consignorPhone"];
        ws.labUploadAdress.text = CJStringWithFormat(@"%@%@",dic[@"consignorAddress"],dic[@"consignorDetailAddress"]);
        ws.strUploadCountyCode = dic[@"consignorCountyCode"];
        ws.strUploadDetailAdress =  dic[@"consignorDetailAddress"];
        ws.strUploadAdress = dic[@"consignorAddress"];

        ws.labDownloadName.text = dic[@"consigneeName"];
        ws.labDownloadPhone.text = dic[@"consigneePhone"];
        ws.labDownloadAdress.text =  CJStringWithFormat(@"%@%@",dic[@"consigneeAddress"],dic[@"consigneeDetailAddress"]);
//        ws.strUploadDetailAdress =  dic[@"consigneeDetailAddress"];
        ws.strDownloadDetailAdress = dic[@"consigneeDetailAddress"];
        ws.strDownloadAdress =  dic[@"consigneeAddress"];
        ws.strDownloadCountyCode =  dic[@"consigneeCountyCode"];
        
        ws.strShipperLongitude = dic[@"shipperLongitude"];
        ws.strShipperLatitude = dic[@"shipperLatitude"];
        ws.strConsigneeLongitude = dic[@"consigneeLongitude"];
        ws.strConsigneeLatitude = dic[@"consigneeLatitude"];
        
        NSDictionary *dict = @{
         @"shipperAddress":CJStringWithFormat(@"%@%@",dic[@"consignorAddress"],dic[@"consignorDetailAddress"]),
         @"consigneeAddress":CJStringWithFormat(@"%@%@",dic[@"consigneeAddress"],dic[@"consigneeDetailAddress"])
        };
        
        NSDictionary *dictLatLong = @{
         @"shipperGrid":CJStringWithFormat(@"%@,%@",ws.strShipperLongitude,ws.strShipperLatitude),
         @"consigneeGrid":CJStringWithFormat(@"%@,%@",ws.strConsigneeLongitude,ws.strConsigneeLatitude)
        };
        
        if ([CJControl getSelectAdressByAmap]) {
            [ws getCommonRouteDistanceByLatLong:dictLatLong];
        }else{
            [ws getCommonRouteDistance:dict];

        }
        
        [header layoutIfNeeded];
        [ws.tableView reloadData];
//        [ws selectHighlightOrNotwitnIndex:1];
        [ws setOtherViewAction];
    };
    [self pushVc:vc];
    
    
}
/// 常发货源
- (void)btnCommonSendSourcesAction{
    WS(ws);
    CommonGoodsSourceVC *vc = [CommonGoodsSourceVC new];
    vc.blockCommonSoures = ^(id anyObject) {
        ws.sourceListModel = (SourceListDetailModel *)anyObject;
        [ws setChangeOrderValue];
        [ws selectHighlightOrNotwitnIndex:2];
    };
    [self pushVc:vc];
    
}

///  0  1  2
/// @param index <#index description#>
- (void)selectHighlightOrNotwitnIndex:(NSInteger )index{

    if (index == 0) {
        self.touchCommonRoute.backgroundColor = [UIColor cjMainColor];
        self.labtouchCommonRoute.textColor = [UIColor cjWhiteColor];
        self.touchAddNewRoute.backgroundColor = [UIColor cjWhiteColor];
        self.labtouchAddNewRoute.textColor = [UIColor cjMainColorText];
        self.touchCommonSendSources.backgroundColor = [UIColor cjWhiteColor];
        self.labtouchCommonSendSources.textColor = [UIColor cjMainColorText];
    }else if (index == 1){
        self.touchCommonRoute.backgroundColor = [UIColor cjWhiteColor];
        self.labtouchCommonRoute.textColor = [UIColor cjMainColorText];
        self.touchAddNewRoute.backgroundColor = [UIColor cjMainColor];
        self.labtouchAddNewRoute.textColor = [UIColor cjWhiteColor];
        self.touchCommonSendSources.backgroundColor = [UIColor cjWhiteColor];
        self.labtouchCommonSendSources.textColor = [UIColor cjMainColorText];
    }else{
        self.touchCommonRoute.backgroundColor = [UIColor cjWhiteColor];
        self.labtouchCommonRoute.textColor = [UIColor cjMainColorText];
        self.touchAddNewRoute.backgroundColor = [UIColor cjWhiteColor];
        self.labtouchAddNewRoute.textColor = [UIColor cjMainColorText];
        self.touchCommonSendSources.backgroundColor = [UIColor cjMainColor];
        self.labtouchCommonSendSources.textColor = [UIColor cjWhiteColor];
    }
    
}

//
- (void)btnSelectGoodsNameAction{
//    [CJAlert showStringDismissWithDelay:@"货物名称"];
    WS(ws);
    SelectGoodsNameVC *vc = [[SelectGoodsNameVC alloc]init];
    if (IsNilOrNull(self.dicGoodsName)) {
        vc.dictData = [[NSDictionary alloc]init];
    }else{
        vc.dictData = self.dicGoodsName;
    }
    
    vc.blockSelectInfo = ^(id anyObject) {
        DLog(@"++++++++ %@",anyObject);
        ws.dicGoodsName = (NSDictionary *)anyObject;
    
        NSArray *list = ws.dicGoodsName[@"cellInfo"];
        ws.fieldGoodsName.text = @"";
        NSString *strCodes = @"";
        for (int i = 0; i < list.count; i++) {
            
            NSArray *array = (NSArray *)list[i];
            
            for (int y = 0; y < array.count; y++) {
                SelectGoodsNameCellModel *mod = (SelectGoodsNameCellModel *)array[y];
                
               
                if (mod.selected) {
//                     DLog(@"========= %@",mod.name);
                    ws.fieldGoodsName.text = CJStringWithFormat(@"%@,%@",self.fieldGoodsName.text,mod.name);
                    strCodes = CJStringWithFormat(@"%@,%@",strCodes,mod.code);
                }
            }
        }
        
        ws.strGoodsNameCodes = [strCodes substringFromIndex:1]   ;//;
        ws.fieldGoodsName.text = [ws.fieldGoodsName.text substringFromIndex:1];
        ws.strGoodsBigTypeCode = anyObject[@"coalBigType"];
        ws.strGoodsBigTypeName = anyObject[@"name"];
    };
    [self pushVc:vc];
}
- (void)btnSelectClearingStaffAction{//选择结算员工
//    WS(ws);
//    JieSuanDriverController *vc = [[JieSuanDriverController alloc]init];
//    vc.type = @"1";
//    vc.blockSlelectedDriver = ^(id anyObject) {
//        NSDictionary *dic = anyObject;
//       self.selectedDriverTextField.text = ws.staffName = dic[@"staffName"];
//        ws.staffCode = dic[@"staffCode"];
//    };
//    [self pushVc:vc];
    UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"请选择" message:@"结算类型" preferredStyle:UIAlertControllerStyleActionSheet];
    UIAlertAction *updateAct = [UIAlertAction actionWithTitle:@"按装货数量" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        self.settlementType = @"0";
        self.selectedDriverTextField.text = @"按装货数量";
    }];
    UIAlertAction *twodateAct = [UIAlertAction actionWithTitle:@"按卸货数量" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        self.settlementType = @"1";
        self.selectedDriverTextField.text = @"按卸货数量";
    }];
    UIAlertAction *theedateAct = [UIAlertAction actionWithTitle:@"按装卸货数量最小值" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        self.settlementType = @"2";
        self.selectedDriverTextField.text = @"按装卸货数量最小值";
    }];
    UIAlertAction *cententAct = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    [alertC addAction:updateAct];
    [alertC addAction:twodateAct];
    [alertC addAction:theedateAct];
    [alertC addAction:cententAct];
    [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alertC animated:YES completion:^{
        
    }];
}
- (void)btnUpLoadNumber4Action{
    UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"请选择" message:@"电子围栏范围" preferredStyle:UIAlertControllerStyleActionSheet];
    UIAlertAction *updateAct = [UIAlertAction actionWithTitle:@"不限" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        self.electronicFenceLabel.text = @"不限";
    }];
    UIAlertAction *twodateAct = [UIAlertAction actionWithTitle:@"0.5千米" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        self.electronicFenceLabel.text = @"0.5";
    }];
    UIAlertAction *theedateAct = [UIAlertAction actionWithTitle:@"0.8千米" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        self.electronicFenceLabel.text = @"0.8";
    }];
    UIAlertAction *foredateAct = [UIAlertAction actionWithTitle:@"1千米" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        self.electronicFenceLabel.text = @"1";
    }];
    [alertC addAction:updateAct];
    [alertC addAction:twodateAct];
    [alertC addAction:theedateAct];
    [alertC addAction:foredateAct];
    [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alertC animated:YES completion:^{
        
    }];
}
/// 所属行业
- (void)btnSelectIndustryNameAction{
    
//    //private String industryCode; //货物所属行业code
//    //
//    //private String industryName;//货物所属行业名称
//    //
//    //private String industryList;//货物所属行业
//    @property (nonatomic,copy) NSString *strIndustryCode;
//    @property (nonatomic,copy) NSString *strIndustryName;
//    @property (nonatomic,copy) NSString *strindustryList;

    SubordIndustryVC *vc = [[SubordIndustryVC alloc]init];
    
    WS(ws);
    vc.blockSuccess = ^(id anyObject) {
        
        DLog(@"==== %@",anyObject);
        NSDictionary *dic = (NSDictionary *)anyObject;
        ws.strIndustryName = dic[@"industryName"];
        ws.strIndustryCode = dic[@"industryCode"];
        ws.strindustryList = dic[@"industryList"];
        ws.fieldIndustryName.text = ws.strIndustryName;
        
    };
    [self pushVc:vc];
    
}


/// 货物数量单位
- (void)btnSelectGoodsNumUnitAction{
    [self btnSelectGoodTypeDicts:CJGetSendgoodsTransferFeeUnits];
}
- (void)btnGoodsPriceUnitAction{
//    [CJAlert showStringDismissWithDelay:@"货物jiage单位"];
}

//损耗单位
- (void)btnGoodsLossUnitAction{
    [self.view endEditing:NO];
//    [CJAlert showStringDismissWithDelay:@"损耗单位"];
//    [self btnSelectGoodTypeDicts:CJGetSendgoodslimitWastageType];
    NSString *strUrl = CJStringWithFormat(@"%@/ntocc-basic-api/dict/listDict",CJBaseUrl);
    NSDictionary *dicPra = @{@"types":CJStringWithFormat(@"limitWastageType%@",self.strGoodsTransferFeeUnits)
                            };
    WS(ws);
    [[HDNetworking sharedHDNetworking] GET:strUrl parameters:dicPra success:^(id  _Nonnull responseObject) {

        DLog(@"==== %@",responseObject);
        NSDictionary *dic = responseObject[0];
        NSMutableArray *arrMutar = [[NSMutableArray alloc]init];
        NSMutableArray *arrMutarCodes = [[NSMutableArray alloc]init];

        [dic[@"dictList"] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
            
            [arrMutar addObject:obj[@"name"]];
            [arrMutarCodes addObject:obj[@"code"]];
            DLog(@"===== %@",arrMutarCodes);
        }];
        [ws btnSelectList:arrMutar listCodes:arrMutarCodes title:dic[@"name"]];
    } failure:^(NSError * _Nonnull error) {

    }];
    
}


- (void)btnSelectList:(NSArray *)list listCodes:(NSMutableArray *)arryCodes title:(NSString *)strTitle{
    
    [self.view endEditing:NO];
    BRStringPickerView *stringPickerView = [[BRStringPickerView alloc]initWithPickerMode:BRStringPickerComponentSingle];
    stringPickerView.title = strTitle;
    stringPickerView.dataSourceArr = list;
    WS(ws);
    stringPickerView.resultModelBlock = ^(BRResultModel *resultModel) {

            if (resultModel.index == 0) {
                ws.labLossUnit.text = resultModel.selectValue;
                ws.strLossCode = arryCodes[resultModel.index];
                ws.fleidLoss.text = @"0";
                ws.fleidLoss.enabled = NO;
                ws.fleidLoss.backgroundColor = [UIColor cjBackgroundColor];
                ws.strLossCode = @"0";
            }else{
                ws.labLossUnit.text = resultModel.selectValue;
                ws.strLossCode = arryCodes[resultModel.index];
                ws.fleidLoss.enabled = YES;
                ws.fleidLoss.backgroundColor = [UIColor cjWhiteColor];
                ws.fleidLoss.text = @"";
            }
   
    };
    
    BRPickerStyle *customStyle = [BRPickerStyle pickerStyleWithThemeColor:[UIColor cjMainColor]];
    stringPickerView.pickerStyle = customStyle;
    [stringPickerView show];
}
- (void)isAdvanceFreightAction{
    NSArray *arr = @[@"否",@"是"];
    [self btnSelectListIsYesOrNo:arr type:@"是否预付"];
}
- (void)isMotorcadeAction{
    NSArray *arr = @[@"否",@"是"];
    [self btnSelectListIsYesOrNo:arr type:@"加入车队"];
}
- (void)isAdvanceFreightNumberAction{
    NSArray *arr = @[@"5",@"10",@"15",@"20",@"25",@"30"];
    [self btnSelectListIsYesOrNo:arr type:@"预付比例"];
}
- (void)isReturnPayMentAction{
    NSArray *arr = @[@"否",@"是"];
    [self btnSelectListIsYesOrNo:arr type:@"是否回单"];
}
- (void)isReturnPayMentNumberAction{
    NSArray *arr = @[@"5",@"10",@"15",@"20"];
    [self btnSelectListIsYesOrNo:arr type:@"回单比例"];
}
- (void)btnSelectListIsYesOrNo:(NSArray *)list type:(NSString *)type{
    [self.view endEditing:NO];
    BRStringPickerView *stringPickerView = [[BRStringPickerView alloc]initWithPickerMode:BRStringPickerComponentSingle];
    stringPickerView.dataSourceArr = list;
    WS(ws);
    stringPickerView.resultModelBlock = ^(BRResultModel *resultModel) {
        if([type isEqualToString:@"是否预付"]){
            ws.isPrepay = list[resultModel.index];
            ws.isAdvanceFreightTitle.text = list[resultModel.index];
            if ([ws.isAdvanceFreightTitle.text isEqualToString:@"否"]) {
                ws.isAdvanceFreightView.hidden = YES;
            }else{
                ws.isAdvanceFreightView.hidden = NO;
            }
        }else if ([type isEqualToString:@"是否回单"]){
            ws.isReceiptPay = list[resultModel.index];
            ws.isReturnPayIsSelecte.text = list[resultModel.index];
            if ([ws.isReturnPayIsSelecte.text isEqualToString:@"否"]) {
                ws.isReturnPayMentView.hidden = YES;
            }else{
                ws.isReturnPayMentView.hidden = NO;
            }
        }else if ([type isEqualToString:@"加入车队"]){
            ws.isVehicleTeam = list[resultModel.index];
            ws.isMotorcadeTitle.text = list[resultModel.index];
        }else if ([type isEqualToString:@"预付比例"]){
            ws.prepayScale = list[resultModel.index];
            ws.isAdvanceFreightNumber.text = list[resultModel.index];
        }else if ([type isEqualToString:@"回单比例"]){
            ws.receiptPayScale = list[resultModel.index];
            ws.isReturnPayMentNumber.text = list[resultModel.index];
        }
           
   
    };
    
    BRPickerStyle *customStyle = [BRPickerStyle pickerStyleWithThemeColor:[UIColor cjMainColor]];
    stringPickerView.pickerStyle = customStyle;
    [stringPickerView show];
}
- (void)btnSelectListHui:(NSArray *)list listCodes:(NSMutableArray *)arryCodes title:(NSString *)strTitle type:(NSString *)type{
    
    [self.view endEditing:NO];
    BRStringPickerView *stringPickerView = [[BRStringPickerView alloc]initWithPickerMode:BRStringPickerComponentSingle];
    stringPickerView.title = strTitle;
    stringPickerView.dataSourceArr = list;
    WS(ws);
    stringPickerView.resultModelBlock = ^(BRResultModel *resultModel) {

            if (resultModel.index == 0) {
                ws.labLossUnit.text = resultModel.selectValue;
                ws.strLossCode = arryCodes[resultModel.index];
                ws.fleidLoss.text = @"0";
                ws.fleidLoss.enabled = NO;
                ws.fleidLoss.backgroundColor = [UIColor cjBackgroundColor];
                ws.strLossCode = @"0";
            }else{
                ws.labLossUnit.text = resultModel.selectValue;
                ws.strLossCode = arryCodes[resultModel.index];
                ws.fleidLoss.enabled = YES;
                ws.fleidLoss.backgroundColor = [UIColor cjWhiteColor];
                ws.fleidLoss.text = @"";
            }
   
    };
    
    BRPickerStyle *customStyle = [BRPickerStyle pickerStyleWithThemeColor:[UIColor cjMainColor]];
    stringPickerView.pickerStyle = customStyle;
    [stringPickerView show];
}

// 运费单价
- (void)btnFreightCostUnitAction{
//    [CJAlert showStringDismissWithDelay:@"运费单价"];
    
    [self btnFreightCostUnitActionType:@"1"];
}
//fieldInSureMoney; // 投保金额
- (void)btnInSureMoneyAction{
//   [CJAlert showStringDismissWithDelay:@"投保金额"];
    [self btnSelectGoodTypeDicts:CJGetSendgoodsInsureType];

}
//fieldOpenInvoiceType 迭代去掉 21-08-13
//- (void)btnOpenInvoiceTypeAction{
////    [CJAlert showStringDismissWithDelay:@"开票方式"];
////    [self btnSelectGoodTypeDicts:CJGetSendgoodsBillingType];
//}

/// 运输方式
- (void)btnTransportTypeAction{
    [self btnSelectGoodTypeDicts:CJTransportType];
}

- (void)btnFreightCostUnitActionType:(NSString *)strType{
    [self.view endEditing:NO];
    NSString *strUrl = CJStringWithFormat(@"%@/ntocc-basic-api/dict/listDict",CJBaseUrl);
    NSDictionary *dicPra = @{
            @"types":CJStringWithFormat(@"goodsTransferFeeUnits%@",self.strGoodsTransferFeeUnits)
                            };
    WS(ws);
    [[HDNetworking sharedHDNetworking] GET:strUrl parameters:dicPra success:^(id  _Nonnull responseObject) {
                
        DLog(@"===== %@",responseObject);
        
        NSDictionary *dic = responseObject[0];
        NSMutableArray *arrMutar = [[NSMutableArray alloc]init];
        NSMutableArray *arrMutarCodes = [[NSMutableArray alloc]init];

        if ([strType isEqualToString:@"1"]) {
            [dic[@"dictList"] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
                [arrMutar addObject:obj[@"name"]];
                [arrMutarCodes addObject:obj[@"code"]];
            }];
            
            
            [ws btnSelectTypeList:arrMutar listCodes:arrMutarCodes title:dic[@"name"]];
        }else{
            NSArray *array = dic[@"dictList"];
            if (array.count > 0) {
                NSDictionary *dic =  array[0];
                ws.labFreightCostUnit.text = dic[@"name"];
                ws.strFreightCostUnit = dic[@"code"];
            }
        }
        
    } failure:^(NSError * _Nonnull error) {
//        DLog(@"++++++++%@",error);
        
    }];

}
- (void)btnTaxFundAction{
    [self.view endEditing:NO];
    BRStringPickerView *stringPickerView = [[BRStringPickerView alloc]initWithPickerMode:BRStringPickerComponentSingle];
    stringPickerView.title = @"税源地列表";
    NSDictionary *dic = CJFetchMyDefault(CJPartyUserCenter);
    NSMutableArray *arr = [@[] mutableCopy];
    NSArray *currentArr = dic[@"taxMultipleSources"];
    if (dic[@"taxMultipleSources"]) {
        for (NSDictionary *dict in dic[@"taxMultipleSources"]) {
            [arr addObject:dict[@"taxName"]];
        }
    }
    stringPickerView.dataSourceArr = arr;
    WS(ws);
    stringPickerView.resultModelBlock = ^(BRResultModel *resultModel) {
        ws.taxFundLabel.text = resultModel.selectValue;
        NSDictionary *dicCode = currentArr[resultModel.index];
        ws.taxFundcode = dicCode[@"code"];
    };
    BRPickerStyle *customStyle = [BRPickerStyle pickerStyleWithThemeColor:[UIColor cjMainColor]];
    stringPickerView.pickerStyle = customStyle;
    [stringPickerView show];
}

- (void)btnSelectTypeList:(NSArray *)list listCodes:(NSMutableArray *)arryCodes title:(NSString *)strTitle{
    
    [self.view endEditing:NO];
    BRStringPickerView *stringPickerView = [[BRStringPickerView alloc]initWithPickerMode:BRStringPickerComponentSingle];
    stringPickerView.title = strTitle;
    stringPickerView.dataSourceArr = list;
    WS(ws);
    stringPickerView.resultModelBlock = ^(BRResultModel *resultModel) {
        
        ws.labFreightCostUnit.text = resultModel.selectValue;
        ws.labHighestPriceUnit.text = resultModel.selectValue;
        ws.strFreightCostUnit = arryCodes[resultModel.index];
        [ws setLabCarNumsRequirAction];
        if ([ws.strFreightCostUnit isEqualToString:@"3"]) {
            
            ws.fleidLoss.text = @"0";
            ws.labLossUnit.text = @"不计";
            ws.fleidLoss.enabled = NO;
            ws.fleidLoss.backgroundColor = [UIColor cjBackgroundColor];
//            ws.touchViewLoss.userInteractionEnabled = NO;
        }else{
//            ws.touchViewLoss.userInteractionEnabled = YES;
            
        }
    };
    
    BRPickerStyle *customStyle = [BRPickerStyle pickerStyleWithThemeColor:[UIColor cjMainColor]];
    stringPickerView.pickerStyle = customStyle;
    [stringPickerView show];
}


- (void)btnSelectGoodTypeDicts:(CJGetSendGoodsType )type{
    [self.view endEditing:YES];
    WS(ws);
    [CJNetWork getSenGoodsDicsTypeinfo:type Success:^(id  _Nullable responseObject) {
        
        DLog(@"====== %@",responseObject);
//        [ws btnSelectTypeAction];
        NSDictionary *dic = responseObject[0];
        NSMutableArray *arrMutar = [[NSMutableArray alloc]init];
        NSMutableArray *arrMutarCodes = [[NSMutableArray alloc]init];

        [dic[@"dictList"] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
            [arrMutar addObject:obj[@"name"]];

            
            switch (type) {
                case CJGetSendgoodsInsureType:
                    [arrMutarCodes addObject:obj[@"code"]];

                    break;
                default:
                    [arrMutarCodes addObject:obj[@"code"]];

                    break;
            }
            
            DLog(@"===== %@",arrMutarCodes);
            
        }];

        [ws btnSelectType:type list:arrMutar listCodes:arrMutarCodes title:dic[@"name"]];
        
    }];
    
}



- (void)btnSelectType:(CJGetSendGoodsType )type list:(NSArray *)list listCodes:(NSMutableArray *)arryCodes title:(NSString *)strTitle{
    
    [self.view endEditing:NO];
    BRStringPickerView *stringPickerView = [[BRStringPickerView alloc]initWithPickerMode:BRStringPickerComponentSingle];
    stringPickerView.title = strTitle;
    stringPickerView.dataSourceArr = list;
    WS(ws);
    stringPickerView.resultModelBlock = ^(BRResultModel *resultModel) {

        switch (type) {
                // 货物数量
            case CJGetSendgoodsTransferFeeUnits:
                ws.labGoodsTransferFeeUnits.text = resultModel.selectValue;
                ws.strGoodsTransferFeeUnits = arryCodes[resultModel.index];
//
                if ([arryCodes[resultModel.index] intValue] == 2) {
                    [self setFieldGoodsNumThreeDecimalPlace:NO];
                    self.fieldGoodsNum.text = @"";
                }else{
                    [self setFieldGoodsNumThreeDecimalPlace:YES];
                }
                
                ws.labGoodsPriceUnit.text = CJStringWithFormat(@"元/%@",resultModel.selectValue);
                ws.labHighestPriceUnit.text = CJStringWithFormat(@"元/%@",resultModel.selectValue);
                // 设置合理损耗不计
                ws.strLossCode = arryCodes[resultModel.index]; //
                
                if (![ws.strLossCode isEqualToString:@"0"]) {
                    ws.strLossCode = CJStringWithFormat(@"%@0",ws.strLossCode);
                }
                
                ws.fleidLoss.enabled = NO;
                ws.fleidLoss.backgroundColor = [UIColor cjBackgroundColor];
                ws.fleidLoss.text = @"0";
                ws.labLossUnit.text = @"不计";
                [ws btnFreightCostUnitActionType:@"0"];
                break;
            case CJGetSendgoodslimitWastageType:
//                ws.labLossUnit.text = resultModel.selectValue;
//                ws.strLossCode = arryCodes[resultModel.index];
                if (resultModel.index == 0) {
                    ws.labLossUnit.text = resultModel.selectValue;
                    ws.strLossCode = arryCodes[resultModel.index];
                    ws.fleidLoss.text = @"0";
                    ws.fleidLoss.enabled = NO;
                    ws.fleidLoss.backgroundColor = [UIColor cjBackgroundColor];
                }else{
                    ws.labLossUnit.text = resultModel.selectValue;
                    ws.strLossCode = arryCodes[resultModel.index];
                    ws.fleidLoss.enabled = YES;
                    ws.fleidLoss.backgroundColor = [UIColor cjWhiteColor];
                    ws.fleidLoss.text = @"";
                }
                break;
            case CJGetSendgoodsInsureType:
                ws.strInSureMoneyCode = arryCodes[resultModel.index];
                ws.fieldInSureMoney.text = resultModel.selectValue;

                break;
//                迭代去掉 21-08-13
//            case CJGetSendgoodsBillingType:
//                ws.strOpenInvoiceType = arryCodes[resultModel.index];
//                ws.fieldOpenInvoiceType.text = resultModel.selectValue;
//                break;
                
            case CJTransportType:
                ws.fieldTransportType.text = resultModel.selectValue;
                ws.strTransportType = arryCodes[resultModel.index];
                break;
            default:
                break;
        }
        
    };
    
    BRPickerStyle *customStyle = [BRPickerStyle pickerStyleWithThemeColor:[UIColor cjMainColor]];
    stringPickerView.pickerStyle = customStyle;
    [stringPickerView show];
}


- (void)btnUpLoadGoodsTimeAction{
//    [CJAlert showStringDismissWithDelay:@"装车时间"];
    [self.view endEditing:NO];
    [self btnShowDataTimeWithType:@"0"];
}

- (void)btnDownLoadGoodsTimeAction{
//    [CJAlert showStringDismissWithDelay:@"卸车时间"];
    [self.view endEditing:NO];
    [self btnShowDataTimeWithType:@"1"];
}


- (void)btnShowDataTimeWithType:(NSString *)strType{
    
    WS(ws);
    BRDatePickerView *datePickerView = [[BRDatePickerView alloc]initWithPickerMode:BRDatePickerModeYMDHM];
    datePickerView.title = strType.intValue == 0 ? @"装车时间":@"卸车时间";
    datePickerView.minDate = [NSDate date];
    datePickerView.maxDate = [NSDate br_setYear:2035 month:5 day:1];
    datePickerView.resultBlock = ^(NSString *selectValue) {

        if (strType.intValue == 0) {
            ws.fieldUpLoadGoodsTime.text = CJStringWithFormat(@"%@:00",selectValue);
//            ws.labStartTime.text = selectValue;
//            ws.strStartTime = selectValue;
        } else {
//            ws.labEndTime.text = selectValue;
//            ws.strEndTime = selectValue;
            ws.fieldDomnLoadCoodsTime.text = CJStringWithFormat(@"%@:00",selectValue);

        }
//        [ws.tableView.mj_header beginRefreshing];
    };
    
    BRPickerStyle *customStyle = [BRPickerStyle pickerStyleWithThemeColor:[UIColor cjMainColor]];
    datePickerView.pickerStyle = customStyle;
    [datePickerView show];

}

/// 是否投保
/// @param sender <#sender description#>
-(void)switchInSureAction:(UISwitch *)sender
{

    if([sender isOn]){
        NSLog(@"turn on");
        self.strIsInsure = @"1";
        self.viewInSureMoney.hidden = NO;
    }else{
        NSLog(@"turned off");
        self.strIsInsure = @"0";
        self.viewInSureMoney.hidden = YES;
        self.strInSureMoneyCode = @"";
//         self.strInSureMoneyCode =  @"0";
        
         self.fieldInSureMoney.text = @"";
    }
    
    [self setLabCarNumsRequirAction];
    [self.viewOthers markDirty];
    [header layoutIfNeeded];
    [self.tableView reloadData];
}


//fieldInSureMoney; //指定司机
- (void)btnIAppointDriverAction{
//   [CJAlert showStringDismissWithDelay:@"指定司机"];
    SelectDriverVC *vc = [[SelectDriverVC alloc]init];
    WS(ws)
    
    // 司机
    vc.blockSeletArr = ^(id anyObject) {
        
        NSArray *list = (NSArray *)anyObject;
        __block NSString *strName = @"";
        __block NSString *strCode = @"";
        
        [list enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            DriverListModel *model = (DriverListModel *)obj;
            if (idx == 0) {
                strName = model.name;
                strCode = model.partyCode;
            }else{
                strName = CJStringWithFormat(@"%@,%@",strName,model.name);
                strCode = CJStringWithFormat(@"%@,%@",strCode,model.partyCode);
            }
        }];
        
        ws.fieldAppointDriver.text = strName;
        ws.strAppointDriverCode = strCode;
        ws.strIsTeam = @"0"; //指定司机来源:0-司机，1-承运分组 ,;
        self.touchClearAppointDriver.hidden = NO;
    };
    
    // 承运分组
    vc.blockDic = ^(id anyObject) {
        NSDictionary *dic = (NSDictionary *)anyObject;
        ws.fieldAppointDriver.text = dic[@"name"];
        ws.strAppointDriverCode = dic[@"code"];
        ws.strIsTeam = @"1"; //指定司机来源:0-司机，1-承运分组 ,;
        self.touchClearAppointDriver.hidden = NO;
    };
    
    [self pushVc:vc];
}

/// 清除指定司机
- (void)btnClearAppointDriverAction{
    
    self.fieldAppointDriver.text = @"";
    self.strAppointDriverCode = @"";
    self.strIsTeam = @""; //指定司机来源:0-司机，1-承运分组 ,;
    self.touchClearAppointDriver.hidden = YES;

}

// fieldUserCarType; //用车类型
- (void)btnUserCarTypeAction{
//   [CJAlert showStringDismissWithDelay:@"用车类型"];
    UseCarTypesVC *vc = [[UseCarTypesVC alloc]init];
    
    if (IsNilOrNull(self.dicUserCarType)) {
        vc.dictData = [[NSDictionary alloc]init];
    }else{
        vc.dictData = self.dicUserCarType;
    }
    
    WS(ws);
    vc.blockSelectInfo = ^(id anyObject) {
//        DLog(@"====== %@",anyObject);
        NSDictionary *dic = (NSDictionary *)anyObject;
        ws.fieldUserCarType.text = dic[@"index"];
        ws.dicUserCarType = dic;
    };
    
    vc.blockCancleInfo = ^(id anyObject) {
        ws.fieldUserCarType.text = @"";
        ws.dicUserCarType = nil;
    };
    
    
    [self pushVc:vc];
}

//fieldUpstreamName
- (void)btnSelectUpstreamCustomAction{
//    [CJAlert showStringDismissWithDelay:@"上游客户"];
    
    if ([CJRegular getIsStrEmpty:self.strUploadCountyCode]) {
        [CJAlert showStringDismissWithDelay:@"先选择路线"];
    }
//    else if([CJRegular getIsStrEmpty:self.fieldGoodsPrice.text]){
//        [CJAlert showStringDismissWithDelay:@"先输入单价"];
//
//    }
    else if([CJRegular getIsStrEmpty:self.fieldGoodsNum.text]){
        [CJAlert showStringDismissWithDelay:@"先输入货物数量"];

    }else if ([CJRegular getIsStrEmpty:self.strGoodsNameCodes]){
        [CJAlert showStringDismissWithDelay:@"先输入选择货物名称"];

    }
    
    
    else{
        UpstreamCustomerVC *vc = [[UpstreamCustomerVC alloc]init];
        vc.strStartCode = self.strUploadCountyCode;  // 120102
        vc.strEndCode = self.strDownloadCountyCode;
//        vc.strPrice = self.fieldGoodsPrice.text;
        vc.strWeight = self.fieldGoodsNum.text;
        vc.strDistance = self.strDistacne;
        vc.strCoalType = self.strGoodsNameCodes;
        vc.strDistance = self.strDistacne;
        WS(ws);
        vc.blockSuccess = ^(id anyObject) {
            ws.upstreamCustomerModel = (UpstreamCustomerModel *)anyObject;
            ws.strUpstreamCode = ws.upstreamCustomerModel.userCode;
            ws.fieldUpstreamName.text = ws.upstreamCustomerModel.upstreamCustomerName;
            [ws getAllFeeAction];
//            ws.fieldUpstreamInFee.text = CJStringWithFormat(@"%0.2f",ws.upstreamCustomerModel.allFee);
            ws.viewUpstreamInFee.hidden = NO;
            [header layoutIfNeeded];
            [ws.tableView reloadData];
        };
        
        [self pushVc:vc];
    }

}

- (void)textFieldDidEndEditing:(UITextField *)textField{
    
    if ( textField == self.fieldGoodsNum) {
        [self getAllFeeAction];
    }
}

- (void)getAllFeeAction{
//    self.fieldGoodsNum.delegate = self;
//    self.fieldGoodsPrice.delegate = self;
    if (IsNilOrNull(self.upstreamCustomerModel)) {
        
    }else{
        
        float allFee = 0.0;
        if (self.upstreamCustomerModel.chargingType == 0) {
           // 单价*吨
            if ([CJRegular getIsStrEmpty:self.fieldGoodsPrice.text ]) {
                [CJAlert showStringDismissWithDelay:@"请填写单价"];
                return;
            }
            allFee = self.upstreamCustomerModel.price*[self.fieldGoodsNum.text floatValue];
        }else if(self.upstreamCustomerModel.chargingType == 1){
            // 单价*吨*距离
            if ([CJRegular getIsStrEmpty:self.fieldGoodsNum.text ]) {
                [CJAlert showStringDismissWithDelay:@"请填写数量"];
                return;
            }
            if ([CJRegular getIsStrEmpty:self.fieldGoodsPrice.text ]) {
                [CJAlert showStringDismissWithDelay:@"请填写单价"];
                return;
            }
            if ([CJRegular getIsStrEmpty:self.labDistance.text ]) {
                [CJAlert showStringDismissWithDelay:@"请选择路线计算价格"];
                return;
            }
             allFee = self.upstreamCustomerModel.price*[self.fieldGoodsPrice.text floatValue] *[self.strDistacne floatValue];
        }else if(self.upstreamCustomerModel.chargingType == 2){
            allFee = self.upstreamCustomerModel.allFee;
        }
        self.fieldUpstreamInFee.text = CJStringWithFormat(@"%@",@(allFee).cj_money_description);
    }
    
}

/// 是
/// @param sender <#sender description#>
-(void)switchCommonSourceAction:(UISwitch *)sender
{
    if([sender isOn]){
        NSLog(@"turn on");
        self.strIsOftenOrder = @"1";
    }else{
        NSLog(@"turned off");
        self.strIsOftenOrder = @"0";
    }
}


///  是否允许报价
/// @param sender <#sender description#>
-(void)switchIsAllowPriceAction:(UISwitch *)sender
{

    if([sender isOn]){
        DLog(@"turn on");
        
        self.strIsQuote = @"1";
        self.viewHighestPrice.hidden = NO;
    }else{
        DLog(@"turned off");
        self.strIsQuote = @"0";
        self.viewHighestPrice.hidden = YES;

    }
    
    [self.viewHighestSuper markDirty];
    [bottomView layoutIfNeeded];
    [self.tableView reloadData];
}

- (void)btnHighestPriceAction{
//    [CJAlert showStringDismissWithDelay:@"最高价单位"];
}

/// 其他页面
- (void)btnOtherViewHiddenOrNotAction{

    // 其他页面部分 显示
    if (self.strViewOthersIsHidden.intValue == 0) {
        self.viewOthers.hidden = NO;
        self.viewOthersLine.hidden = NO;
        self.strViewOthersIsHidden = @"1";
    }else{
        self.viewOthers.hidden = YES;
        self.viewOthersLine.hidden = YES;
        self.strViewOthersIsHidden = @"0";
    }
    
    WS(ws);
    [UIView animateWithDuration:0.5 animations:^{
        CGAffineTransform transform = ws.imgVOther.transform;
        transform = CGAffineTransformRotate(transform, M_PI);
        ws.imgVOther.transform = transform;
    }];
    
    [header layoutIfNeeded];
    [self.tableView reloadData];
}

/// 设置其他 隐藏页面的部分
- (void)setOtherViewAction{
    
    if (self.strViewOthersIsHidden.intValue == 0) {
        self.viewOthers.hidden = NO;
//        self.viewOthersLine.hidden = NO;
//        self.strViewOthersIsHidden = @"1";
        self.viewOthers.hidden = YES;
//        self.viewOthersLine.hidden = YES;
//        self.strViewOthersIsHidden = @"0";
//        [header layoutIfNeeded];
//        [self.tableView reloadData];
        
    }else{
        self.viewOthers.hidden = YES;
//        self.viewOthersLine.hidden = YES;
//        self.strViewOthersIsHidden = @"0";
        self.viewOthers.hidden = NO;
//        self.viewOthersLine.hidden = NO;
//        self.strViewOthersIsHidden = @"1";
    }
    
    [header layoutIfNeeded];
    [self.tableView reloadData];
    
}

- (void)btnIsAgreeAction{
    
    if (self.strIsAgree.intValue == 0) {
        self.strIsAgree = @"1";
        self.imgVAgree.image = [UIImage imageNamed:@"selected"];
    }else{
        self.strIsAgree = @"0";
        self.imgVAgree.image = [UIImage imageNamed:@"zcj_unSelected"];

    }
}

- (void)btnProtocolDetailAction{
//    [CJAlert showStringDismissWithDelay:@"协议详情"];
    
    //    0716 release0716-agreement-newhtml 修改协议地址传参agreementType：协议类型:1=司机端隐私协议/2=司机端用户协议/3=司机端注销协议/4=司机端物流协议/5=接单协议/6=司机端SDK协议/7=货主端隐私协议/8=货主端用户协议/9=货主端注销协议/10=货主端物流协议/11=货主端SDK协议/12=PC端隐私协议/13=PC端用户协议/14=PC端物流协议/15=网商协议  例如 /agreement/agreement.html?agreementType=1
    CJWKWebViewVC *vc = [CJWKWebViewVC new];
    vc.strTitle = @"物流协议";
    vc.strUrl = CJStringWithFormat(@"%@/agreement/agreement.html?agreementType=10",CJBaseUrl);
    [self pushVc:vc];
}


- (void)setFieldLimit{
    
    //货物数量
//    self.fieldGoodsNum.textFieldType = CJTextFieldStringTypeMoneyValue;
//    self.fieldGoodsNum.maxLength = CJTextLengthTen;
    [self setFieldGoodsNumThreeDecimalPlace:YES];
    //货物单价
    self.fieldGoodsPrice.textFieldType = CJTextFieldStringTypeMoneyValue;
    self.fieldGoodsPrice.maxLength = CJTextLengthTen;
    // 合理损耗
    self.fleidLoss.textFieldType = CJTextFieldStringTypeMoneyValue;
    self.fleidLoss.maxLength = CJTextLengthTen;
    // 运费单价
    self.fieldFreightCost.textFieldType = CJTextFieldStringTypeMoneyValue;
    self.fieldFreightCost.maxLength = CJTextLengthTen;
    // 车数要求
    self.fieldCarNumsRequir.textFieldType = CJTextFieldStringTypeNumber;
    self.fieldCarNumsRequir.maxLength = CJTextLengthTen;
    //运输要求
    self.fieldTranRequirement.textFieldType = CJTextFieldStringTypeNone;
    self.fieldTranRequirement.maxLength = CJTextLengthMax;
    // 最高价
    self.fieldHighestPrice.textFieldType = CJTextFieldStringTypeMoneyValue;
    self.fieldHighestPrice.maxLength = CJTextLengthTen;
    //应收
    self.fieldUpstreamInFee.textFieldType = CJTextFieldStringTypeMoneyValue;
    self.fieldUpstreamInFee.maxLength = 20;
    
}

/// 设置车数要求是否必填
- (void)setLabCarNumsRequirAction{
    
    if ([self.labFreightCostUnit.text isEqualToString:@"元/车"] || [self.strIsInsure isEqualToString:@"1"]){
        self.labCarNumsRequir.hidden = NO;
    }else{
        self.labCarNumsRequir.hidden = YES;
    }
}

/// 货物数鲁是否三位小数
/// @param isYes <#isYes description#>
- (void)setFieldGoodsNumThreeDecimalPlace:(BOOL )isYes{
    
    if (isYes) {
        self.fieldGoodsNum.textFieldType = CJTextFieldStringTypeThreeDecimalPlaces;
        self.fieldGoodsNum.maxLength = 16;
    }else{
        self.fieldGoodsNum.textFieldType = CJTextFieldStringTypeNumber;
        self.fieldGoodsNum.maxLength = 20;
    }
}


/// 提交订单
- (void)btnSubmintOrderAction{
    [self.view endEditing:YES];
    NSMutableDictionary *dicData = [[NSMutableDictionary alloc]init];
    

    if (self.viewAdress.hidden == YES) {

        [CJAlert showStringDismissWithDelay:@"请选择配送路线"];

    }
    else if ([CJRegular getIsStrEmpty:self.strGoodsNameCodes] || [CJRegular getIsStrEmpty:self.strGoodsBigTypeCode] ) {

        [[[AFViewShaker alloc] initWithView:self.fieldGoodsName] shakeWithDuration:[ShakerTime floatValue] completion:^{
            [CJAlert showStringDismissWithDelay:@"请点击选择货物名称"];
        }];
    }
    else if ([CJRegular getIsStrEmpty:self.fieldGoodsNum.text]){
        [[[AFViewShaker alloc] initWithView:self.fieldGoodsNum] shakeWithDuration:[ShakerTime floatValue] completion:^{
            [CJAlert showStringDismissWithDelay:@"请填写货物数量"];

        }];
    }
    else if ([CJRegular getIsStrEmpty:self.fieldGoodsPrice.text]){
        [[[AFViewShaker alloc] initWithView:self.fieldGoodsPrice] shakeWithDuration:[ShakerTime floatValue] completion:^{
            [CJAlert showStringDismissWithDelay:@"请填写货物单价"];

        }];
    }
    else if ([CJRegular getIsStrEmpty:self.fleidLoss.text]){
        [[[AFViewShaker alloc] initWithView:self.fleidLoss] shakeWithDuration:[ShakerTime floatValue] completion:^{
            [CJAlert showStringDismissWithDelay:@"请填写合理损耗"];

        }];
    }
    else if ([CJRegular getIsStrEmpty:self.strLossCode]){
        [CJAlert showStringDismissWithDelay:@"选择合理损耗单位"];
//        labFreightCostUnit
    }
    else if ([CJRegular getIsStrEmpty:self.fieldFreightCost.text]){
        [[[AFViewShaker alloc] initWithView:self.fieldFreightCost] shakeWithDuration:[ShakerTime floatValue] completion:^{
            [CJAlert showStringDismissWithDelay:@"请填写运费单价"];

        }];
    }
    else if ([CJRegular getIsStrEmpty:self.strFreightCostUnit]){
        [CJAlert showStringDismissWithDelay:@"请选择运费单价单位"];

    }
    
    
    
    
//    else if ([CJRegular getIsStrEmpty:self.fieldCarNumsRequir.text]){
//        [[[AFViewShaker alloc] initWithView:self.fieldCarNumsRequir] shakeWithDuration:[ShakerTime floatValue] completion:^{
//            [CJAlert showStringDismissWithDelay:@"请填写车数要求"];
//
//        }];
//    }
    else if ([CJRegular getIsStrEmpty:self.fieldUpLoadGoodsTime.text]){
        [[[AFViewShaker alloc] initWithView:self.fieldUpLoadGoodsTime] shakeWithDuration:[ShakerTime floatValue] completion:^{
            [CJAlert showStringDismissWithDelay:@"请选择时间"];

        }];
    }else if ([CJRegular getIsStrEmpty:self.fieldDomnLoadCoodsTime.text]){
        [[[AFViewShaker alloc] initWithView:self.fieldDomnLoadCoodsTime] shakeWithDuration:[ShakerTime floatValue] completion:^{
            [CJAlert showStringDismissWithDelay:@"请选择时间"];

        }];
    }
//    else if ([CJRegular getIsStrEmpty:self.zhuanghuoAddressTextField.text]){
//        [[[AFViewShaker alloc] initWithView:self.zhuanghuoAddressTextField] shakeWithDuration:[ShakerTime floatValue] completion:^{
//            [CJAlert showStringDismissWithDelay:@"请填写装货地址简称"];
//
//        }];
//    }
//    else if ([CJRegular getIsStrEmpty:self.xiehuoAddressTextField.text]){
//        [[[AFViewShaker alloc] initWithView:self.xiehuoAddressTextField] shakeWithDuration:[ShakerTime floatValue] completion:^{
//            [CJAlert showStringDismissWithDelay:@"请填写卸货地址简称"];
//
//        }];
//    }
//    else if ([CJRegular getIsStrEmpty:self.fieldTranRequirement.text]){
//        [[[AFViewShaker alloc] initWithView:self.fieldTranRequirement] shakeWithDuration:[ShakerTime floatValue] completion:^{
//            [CJAlert showStringDismissWithDelay:@"请填写运输要求"];
//
//        }];
//    }
//    else if ([CJRegular getIsStrEmpty:self.fieldAppointDriver.text] || [CJRegular getIsStrEmpty:self.strAppointDriverCode]){
//        [[[AFViewShaker alloc] initWithView:self.fieldAppointDriver] shakeWithDuration:[ShakerTime floatValue] completion:^{
//            [CJAlert showStringDismissWithDelay:@"请选择指定司机"];
//
//        }];
//    }
//    else if ([CJRegular getIsStrEmpty:self.fieldOpenInvoiceType.text] || [CJRegular getIsStrEmpty:self.strOpenInvoiceType]){
//        [[[AFViewShaker alloc] initWithView:self.fieldAppointDriver] shakeWithDuration:[ShakerTime floatValue] completion:^{
//            [CJAlert showStringDismissWithDelay:@"请选择指开票方式 "];
//
//        }];
//    }
    else if (self.strIsAgree.intValue == 0){
        [CJAlert showStringDismissWithDelay:@"请阅读并同意物流协议"];
    }else if ([self.strIsQuote isEqualToString:@"0"] && ([CJRegular getIsStrEmpty:self.fieldAppointDriver.text] || [CJRegular getIsStrEmpty:self.strAppointDriverCode])){
        [CJAlert showStringDismissWithDelay:@"请选择指定司机"];
    }

    else{
        
        
        if ([self.labFreightCostUnit.text isEqualToString:@"元/车"] ){
            // 此时车数要求必填
            if ([CJRegular getIsStrEmpty:[CJControl getThreeUnaryValueStr:self.fieldCarNumsRequir.text]]){
                
                [[[AFViewShaker alloc] initWithView:self.fieldCarNumsRequir] shakeWithDuration:[ShakerTime floatValue] completion:^{
                    [CJAlert showStringDismissWithDelay:@"请填写正确的车数要求"];

                }];
               
                return;
            }
        
        }
        
        if ([self.strIsInsure isEqualToString:@"1"]){
            // 此时车数要求必填
            if (![CJRegular getCarNumsRequir:[CJControl getThreeUnaryValueStr:self.fieldCarNumsRequir.text] length:CJCarNumsLength]){
                
                [[[AFViewShaker alloc] initWithView:self.fieldCarNumsRequir] shakeWithDuration:[ShakerTime floatValue] completion:^{
                    [CJAlert showStringDismissWithDelay:@"请填写正确的车数要求"];
                }];
               
                return;
            }
        
        }
        
        // 是否投保的问题
        if ([self.strIsInsure isEqualToString:@"1"]) {

            if ([CJRegular getIsStrEmpty:self.fieldInSureMoney.text]) {
                [[[AFViewShaker alloc] initWithView:self.fieldInSureMoney] shakeWithDuration:[ShakerTime floatValue] completion:^{
                    [CJAlert showStringDismissWithDelay:@"请选择投保金额"];

                }];
                return;
            }
        }else{
            self.strInSureMoneyCode = @"";
        }

        // 是否允许报价
        if ([self.strIsQuote isEqualToString:@"1"]) {

            if ([CJRegular getIsStrEmpty:self.fieldHighestPrice.text]) {
//                [[[AFViewShaker alloc] initWithView:self.fieldHighestPrice] shakeWithDuration:[ShakerTime floatValue] completion:^{
                    [CJAlert showStringDismissWithDelay:@"请填写最高价"];

//                }];
                return;
            }
        }else{
            self.fieldHighestPrice.text = @"0";
        }
    
    if ([CJRegular compareDate:self.fieldUpLoadGoodsTime.text withDate:self.fieldDomnLoadCoodsTime.text]) {
        
    }else{
        [CJAlert showStringDismissWithDelay:@"卸车时间必须大于装车时间"];
        return;
    }
        
    if ([CJRegular getIsStrEmpty:self.fieldUpstreamName.text]) {
        self.fieldUpstreamInFee.text = @"0";
    }else{
        if ([CJRegular getIsStrEmpty:self.fieldUpstreamInFee.text]) {
            [CJAlert showStringDismissWithDelay:@"请填写应付金额"];
            return;
        }
    }

   
    if ([CJControl getIsCompany]) {
        if ([CJRegular getIsStrEmpty:self.strUpstreamCode]) {
            self.fieldUpstreamInFee.text = @"0";
        }else{
            if ([CJRegular getIsStrEmpty:self.fieldUpstreamInFee.text]) {
                [CJAlert showStringDismissWithDelay:@"请填写应收金额"];
                return;
            }
        }
    }
    
        if ([CJControl getIsEmpty:self.fieldTransportType.text]) {
            [CJAlert showStringDismissWithDelay:@"请选择运输方式"];
            return;
        }
        
        //    //private String industryCode; //货物所属行业code
        //    //
        //    //private String industryName;//货物所属行业名称
        //    //
        //    //private String industryList;//货物所属行业
        //    @property (nonatomic,copy) NSString *strIndustryCode;
        //    @property (nonatomic,copy) NSString *strIndustryName;
        //    @property (nonatomic,copy) NSString *strindustryList;
        
        
        if ([CJControl getIsTax]) {
            
            if ([self.strIndustryCode isEqualToString:@""]) {
                [CJAlert showStringDismissWithDelay:@"请选择所属行业"];
                
                return;
            }
            
            [dicData setValue:self.strIndustryCode forKey:@"industryCode"];
            [dicData setValue:self.strIndustryName forKey:@"industryName"];
            [dicData setValue:self.strindustryList forKey:@"industryList"];
        }
        
        if (self.taxFundcode.length == 0) {
            [CJAlert showStringDismissWithDelay:@"请选择税源地"];
            return;
        }
        
//         if ([CJRegular getIsStrEmpty:self.fieldCarNumsRequir.text]){
//
//        }
        [dicData setValue:self.strDownloadAdress forKey:@"consigneeAddress"];//收货地址 ,
        [dicData setValue:self.strDownloadDetailAdress forKey:@"consigneeDetailAddress"];//: 收货详细地址 ,
        [dicData setValue:self.labDownloadName.text forKey:@"consigneeName"];//
        [dicData setValue:self.labDownloadPhone.text forKey:@"consigneePhone"];//
        [dicData setValue:self.strDownloadCountyCode forKey:@"consigneeSubdivisionCode"];//收货国家行政区划代码 ,
        [dicData setValue:self.strUploadAdress forKey:@"shipperAddress"];//
        [dicData setValue:self.strUploadDetailAdress forKey:@"shipperDetailAddress"];//
        [dicData setValue:self.labUploadName.text forKey:@"shipperName"];//
        [dicData setValue:self.labUploadPhone.text forKey:@"shipperPhone"];//
        [dicData setValue:self.strUploadCountyCode forKey:@"shipperSubdivisionCode"];//

        [dicData setValue:self.strGoodsBigTypeCode forKey:@"coalBigType"];//optional): 货物名称编码（大类） ,
        [dicData setValue:self.strGoodsBigTypeName forKey:@"coalBigTypeName"];
        
        [dicData setValue:self.strGoodsNameCodes forKey:@"coalType"];// 货物名称名称（小类） ,
        [dicData setValue:self.fieldGoodsName.text forKey:@"coalTypeName"];
//        if(self.selectedDriverTextField.text.length != 0){
//            [dicData setValue:self.staffCode forKey:@"staffCode"];
//            [dicData setValue:self.staffName forKey:@"staffName"];
//        }
        if(self.selectedDriverTextField.text.length != 0){
            [dicData setValue:self.settlementType forKey:@"settlementType"];
        }
        if(![self.electronicFenceLabel.text isEqualToString:@"不限"]){
            [dicData setValue:self.electronicFenceLabel.text forKey:@"addressFence"];
        }
        [dicData setValue:self.fieldGoodsNum.text forKey:@"weight"];//货物数量
        [dicData setValue:self.strGoodsTransferFeeUnits forKey:@"coalUnit"];//货物单位 0：吨 1：立方米，2-件 ,
        [dicData setValue:self.labGoodsTransferFeeUnits.text forKey:@"coalUnitName"];//货物单位 0：吨 1：立方米，2-件 ,
        [dicData setValue:self.labFreightCostUnit.text forKey:@"isTrunkName"];
        [dicData setValue:self.fieldFreightCost.text forKey:@"price"];//成交单价--非含税价--司机单价 , 运费单价
    
        [dicData setValue:self.fieldGoodsPrice.text forKey:@"coalPrice"];// 货物价值单价 b
    
        [dicData setValue:self.fleidLoss.text forKey:@"limitWastageAmount"];// 货物损耗数量 /kg
        [dicData setValue:self.labLossUnit.text forKey:@"limitWastageTypeName"];// 货物损耗数量 /kg
        [dicData setValue:self.strLossCode forKey:@"limitWastageType"];// 
        [dicData setValue:self.strFreightCostUnit forKey:@"isTrunk"]; //货物运费单位：0-元/吨，1-元/方，2-元/件，3-元/车

        [dicData setValue:[CJRegular getIsStrEmpty:self.fieldCarNumsRequir.text] ? @"0":self.fieldCarNumsRequir.text forKey:@"coalNumber"];// 需求车数 ,
        [dicData setValue:self.fieldUpLoadGoodsTime.text forKey:@"lastLoadingTime"];//装货截止时间 ,
        [dicData setValue:self.fieldDomnLoadCoodsTime.text forKey:@"lastUnloadingTime"];// 卸货截止时间 ,
        [dicData setValue:self.zhuanghuoAddressTextField.text forKey:@"addressProfile"];
        [dicData setValue:self.xiehuoAddressTextField.text forKey:@"addressFill"];
        
        // 距离
        [dicData setValue:self.strDistacne forKey:@"distance"];//
        [dicData setValue:self.strIsInsure forKey:@"isInsure"];// 投保类别：0-不投保
        [dicData setValue:self.strInSureMoneyCode forKey:@"insuranceAmount"];//保额 ,
        [dicData setValue:self.strInSureMoneyCode forKey:@"insuranceFee"]; //单车保险费用
        [dicData setValue:self.strInSureMoneyCode forKey:@"insuranceCode"]; //insuranceCode
        [dicData setValue:self.fieldInSureMoney.text forKey:@"insuranceFeeName"]; //保费类型名称
        
        [dicData setValue:self.strAppointDriverCode forKey:@"pushTarget"];// 指定司机 fieldAppointDriver
        [dicData setValue:self.fieldAppointDriver.text forKey:@"pushTargetName"];// 指定司机
//        迭代去掉 21-08-13
//        [dicData setValue:self.strOpenInvoiceType forKey:@"billingType"];// 开票方式
//        [dicData setValue:self.fieldOpenInvoiceType.text forKey:@"billingTypeName"];//
        [dicData setValue:self.strIsOftenOrder forKey:@"isOftenOrder"];
        // 运输方式
        [dicData setValue:self.strTransportType forKey:@"transportType"];
        [dicData setValue:self.fieldTransportType.text forKey:@"transportTypeName"];

        [dicData setValue:self.fieldTranRequirement.text forKey:@"coalName"]; // 运输要求
    
        [dicData setValue:self.strIsQuote forKey:@"isQuote"];
        [dicData setValue:self.fieldHighestPrice.text forKey:@"maxPrice"];

        [dicData setValue:self.fieldUserCarType.text forKey:@"pushVehicleUse"]; // 用车类型
        // ws.strIsTeam = @"0"; //指定司机来源:0-司机，1-承运分组 ,;
        [dicData setValue:self.strIsTeam forKey:@"isTeam"]; //指定司机来源:0-司机，1-承运分组
        [dicData setValue:self.strUpstreamCode forKey:@"upstreamCode"]; //上游客户编码
        [dicData setValue:self.fieldUpstreamName.text forKey:@"upstreamName"]; //上游客户编码
        [dicData setValue:self.fieldUpstreamInFee.text forKey:@"inFee"]; // 上游客户应付
        
        // 装卸货地经纬度
        [dicData setValue:self.strShipperLongitude forKey:@"shipperLongitude"];
        [dicData setValue:self.strShipperLatitude forKey:@"shipperLatitude"];
        [dicData setValue:self.strConsigneeLongitude forKey:@"consigneeLongitude"];
        [dicData setValue:self.strConsigneeLatitude forKey:@"consigneeLatitude"];
        [dicData setValue:self.taxFundcode forKey:@"taxLocationCode"];
        
        if([self.isVehicleTeam isEqualToString:@"否"]){
            [dicData setValue:@"0" forKey:@"isVehicleTeam"];
        }else{
            [dicData setValue:@"1" forKey:@"isVehicleTeam"];
        }
        if([self.isPrepay isEqualToString:@"否"]){
            [dicData setValue:@"0" forKey:@"isPrepay"];
        }else{
            [dicData setValue:@"1" forKey:@"isPrepay"];
            if([self.prepayScale intValue] <= 0){
                [CJAlert showStringDismissWithDelay:@"请选择预付比例"];
                return;
            }
            [dicData setValue:self.prepayScale forKey:@"prepayScale"];
        }
        if([self.isReceiptPay isEqualToString:@"否"]){
            [dicData setValue:@"0" forKey:@"isReceiptPay"];
        }else{
            [dicData setValue:@"1" forKey:@"isReceiptPay"];
            if([self.receiptPayScale intValue] <= 0){
                [CJAlert showStringDismissWithDelay:@"请选择回单比例"];
                return;
            }
            [dicData setValue:self.receiptPayScale forKey:@"receiptPayScale"];
        }

        if ([dicData[@"isTrunk"] intValue] == 0 &&  [dicData[@"price"] floatValue] >= 400) {
            NSString *str = CJStringWithFormat(@"目前平台单价最高为381元/吨,而您输入的单价是%@元/吨",dicData[@"price"]);
            UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"温馨提示!" message:str preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction* actionsentient = [UIAlertAction actionWithTitle:@"修改单价" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
               
            }];
            UIAlertAction* action = [UIAlertAction actionWithTitle:@"已确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                [self networkingDownDic:dicData];
            }];
            [alert addAction:actionsentient];
            [alert addAction:action];
            [self presentViewController:alert animated:YES completion:nil];
        }else{
            [self networkingDownDic:dicData];
        }
       
        
    }

}
- (void)networkingDownDic:(NSMutableDictionary *)dicData{
    DLog(@"====== %@",[CJControl convertToJsonDataFromDic:dicData]);

    NSString *strURL = CJStringWithFormat(@"%@/ntocc-tms-api/order",CJBaseUrl);

    if (self.strIsChangeOrder.intValue == 1) {
        [dicData setValue:self.sourceListModel.code forKey:@"code"];
        
        WS(ws);
        [[HDNetworking sharedHDNetworking] dataTaskWithHTTPMethod:PutType url:strURL parameters:@{@"orderDTO":[CJControl convertToJsonDataFromDic:dicData]} status:OperationTip success:^(id  _Nonnull responseObject) {
           
            [ws setDefaultValue];
            [ws sedErweimaNetworking:self.sourceListModel];
        } failure:^(NSError * _Nonnull error) {
            
        }];
        
    }else{
        
        WS(ws);
        [[HDNetworking sharedHDNetworking] dataTaskWithHTTPMethod:PostType url:strURL parameters:@{@"orderDTO":[CJControl convertToJsonDataFromDic:dicData]} status:OperationTip success:^(id  _Nonnull responseObject) {
            
            [ws setDefaultValue];
            [ws sedErweimaNetworkingDic:responseObject];
//                if (ws.strIsAgainOrder.intValue == 1) {
//                    [ws pop];
//                }else{
//                    [ws popToTabVCAtIndex:1];
//                }
//
        } failure:^(NSError * _Nonnull error) {
            
        }];
        
    }
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 0.01;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"SendGoodsCell";
    SendGoodsCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[SendGoodsCell alloc] initWithFlex:nil reuseIdentifier:identifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
    }
    return cell;
}

- (CJTableView *)tableView{
    if (!_tableView) {
        _tableView = CJTableView.tbInitFrameStyle(CGRectMake(0, kTopHeight + topView.height + CJTableToTopHeight, SCREEN_WIDTH, SCREEN_HEIGHT-kTopHeight - topView.height - CJTableToTopHeight),UITableViewStylePlain)
        .tbDelegate(self)
        .tbDataSource(self)
        .tbSetOther(YES)
        .tbEstimatedRowHeight(YES)
        ;
    }
    
    return _tableView;
}


#pragma mark ----------OCR 识别

- (void)selelctOCRRecognize{
    
    WS(ws);
    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    UIAlertAction *change = [UIAlertAction actionWithTitle:@"OCR识别" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [ws uploadImgV];

    }];
    
    UIAlertAction *seeBig = [UIAlertAction actionWithTitle:@"模板查看" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [[XLImageViewer shareInstanse] showNetImages:@[@"https://ntocc-test.obs.cn-north-4.myhuaweicloud.com/2020-01-13/87f8bc47c1e64da7810827fc91e353ba.png"] index:0 fromImageContainer:ws.view];
    }];
    
    UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [alertVC dismissViewControllerAnimated:NO completion:^{
            
        }];
    }];
    
    [alertVC addAction:change];
    [alertVC addAction:seeBig];
    [alertVC addAction:cancle];

    [self presentViewController:alertVC animated:YES completion:nil];
    
}

- (void)uploadImgV{
    WS(ws);
    [GetPhoto getPhoto:self completion:^(UIImage *curImage, NSData *imageData) {
        
         [ws upLoadImageUImage:curImage withNSData:imageData];
    }];
    
}

- (void)upLoadImageUImage:(UIImage *)img withNSData:(NSData *)imageData{
     WS(ws);
    
    [CJNetWork upLoadImageUImage:img withNSData:imageData Success:^(id  _Nullable responseObject) {
        
        NSString *strImgUrl = (NSString *)responseObject;
        
        MyImgVAlertView *alert = [[MyImgVAlertView alloc]initWithTitle:@"" strImgV:strImgUrl ClickOnSure:^(NSString * _Nonnull strSure) {
            [ws uploadImgVURLGetData:(NSString *)responseObject];

        } ClickOnCancle:^(NSString * _Nonnull strCancle) {
            
        }];
        alert.center = KEYWINDOW.center;
        WLAlertView * alertView = [[WLAlertView alloc]init];
        alertView.containerView = alert;
        alertView.isTouchOtherUndissmiss = YES;
        [alertView show];
        
        
    }];


}

- (void)uploadImgVURLGetData:(NSString *)str{
    
        NSString *strURL = CJStringWithFormat(@"%@/ntocc-tps-api/ocr/card",CJBaseUrl);
        NSDictionary *dicPar = @{
                                 @"image":str,
                                 @"ocrType":@"ocrTmsOrderInfo"
        };
    
        WS(ws);
        [[HDNetworking sharedHDNetworking] GET:strURL parameters:dicPar success:^(id  _Nonnull responseObject) {
    
            DLog(@"++++++++%@",responseObject);
            NSDictionary *dic = (NSDictionary *)responseObject;
            NSError * error ;
            ws.sourceListModel = [[SourceListDetailModel alloc]initWithDictionary:dic error:&error];
            [ws setChangeOrderValue];
    
        } failure:^(NSError * _Nonnull error) {
            DLog(@"++++++++%@",error);
    
        }];
    
    
    
    
//    NSString *strURL = CJStringWithFormat(@"%@/ntocc-tps-api/ocr",CJBaseUrl);
//    NSDictionary *dicPar = @{
//                             @"imageUrl":str,
//    };
//
//    WS(ws);
//    [[HDNetworking sharedHDNetworking] PUT:strURL parameters:dicPar success:^(id  _Nonnull responseObject) {
//
//        DLog(@"++++++++%@",responseObject);
//        NSDictionary *dic = (NSDictionary *)responseObject;
//        NSError * error ;
//        ws.sourceListModel = [[SourceListModel alloc]initWithDictionary:dic error:&error];
//        [ws setChangeOrderValue];
//
//    } failure:^(NSError * _Nonnull error) {
//        DLog(@"++++++++%@",error);
//
//    }];
}
- (void)sedErweimaNetworking:(SourceListDetailModel *)model{
    [[UIApplication sharedApplication].keyWindow addSubview:self.bgView];
    [self networkReweima:model.code];
    self.titAddArr = [NSMutableArray array];
    [self.titAddArr addObject:CJStringWithFormat(@"%@",model.coalTypeName)];
    [self.titAddArr addObject:CJStringWithFormat(@"%@",model.shipperAddress)];
    [self.titAddArr addObject:CJStringWithFormat(@"%@",model.shipperDetailAddress)];
    [self.titAddArr addObject:CJStringWithFormat(@"%@",model.consigneeAddress)];
    [self.titAddArr addObject:CJStringWithFormat(@"%@",model.consigneeDetailAddress)];
    [self.titAddArr addObject:CJStringWithFormat(@"%@",model.lastLoadingTime)];
    [self.titAddArr addObject:CJStringWithFormat(@"%@",model.lastUnloadingTime)];
    self.infroLabel.attributedText = [self stringColorStr:@"货物信息:" String:self.titAddArr.firstObject Color:[UIColor blueColor]];
    self.zhAddLabel.attributedText = [self stringColorStr:@"装货市区:" String:self.titAddArr[1] Color:[UIColor blueColor]];
    self.zhDetileAddLabel.attributedText = [self stringColorStr:@"详细地址:" String:self.titAddArr[2] Color:[UIColor blueColor]];
    self.xhAddLabel.attributedText = [self stringColorStr:@"卸货市区:" String:self.titAddArr[3] Color:[UIColor blueColor]];
    self.xhDetileAddLabel.attributedText = [self stringColorStr:@"详细地址:" String:self.titAddArr[4] Color:[UIColor blueColor]];
    self.zhStateTime.attributedText = [self stringColorStr:@"装车时间:" String:self.titAddArr[5] Color:[UIColor blueColor]];
    self.xhEndTime.attributedText = [self stringColorStr:@"卸货时间:" String:self.titAddArr.lastObject Color:[UIColor blueColor]];
}
- (void)sedErweimaNetworkingDic:(NSMutableDictionary *)dic{
    [[UIApplication sharedApplication].keyWindow addSubview:self.bgView];
    [self networkReweima:dic[@"code"]];
    self.titAddArr = [NSMutableArray array];
    [self.titAddArr addObject:CJStringWithFormat(@"%@",dic[@"coalTypeName"])];
    [self.titAddArr addObject:CJStringWithFormat(@"%@",dic[@"shipperAddress"])];
    [self.titAddArr addObject:CJStringWithFormat(@"%@",dic[@"shipperDetailAddress"])];
    [self.titAddArr addObject:CJStringWithFormat(@"%@",dic[@"consigneeAddress"])];
    [self.titAddArr addObject:CJStringWithFormat(@"%@",dic[@"consigneeDetailAddress"])];
    [self.titAddArr addObject:CJStringWithFormat(@"%@",dic[@"lastLoadingTime"])];
    [self.titAddArr addObject:CJStringWithFormat(@"%@",dic[@"lastUnloadingTime"])];
    self.infroLabel.attributedText = [self stringColorStr:@"货物信息:" String:self.titAddArr.firstObject Color:[UIColor blueColor]];
    self.zhAddLabel.attributedText = [self stringColorStr:@"装货市区:" String:self.titAddArr[1] Color:[UIColor blueColor]];
    self.zhDetileAddLabel.attributedText = [self stringColorStr:@"详细地址:" String:self.titAddArr[2] Color:[UIColor blueColor]];
    self.xhAddLabel.attributedText = [self stringColorStr:@"卸货市区:" String:self.titAddArr[3] Color:[UIColor blueColor]];
    self.xhDetileAddLabel.attributedText = [self stringColorStr:@"详细地址:" String:self.titAddArr[4] Color:[UIColor blueColor]];
    self.zhStateTime.attributedText = [self stringColorStr:@"装车时间:" String:self.titAddArr[5] Color:[UIColor blueColor]];
    self.xhEndTime.attributedText = [self stringColorStr:@"卸货时间:" String:self.titAddArr.lastObject Color:[UIColor blueColor]];
}
- (void)networkReweima:(NSString *)codID{
    NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
    [dict setValue:codID forKey:@"mainOrderCode"];
    [[HDNetworking sharedHDNetworking] GET:CJStringWithFormat(@"%@/ntocc-test-api/QrTakeOrder/testToAndroid",CJBaseUrl) parameters:dict success:^(id  _Nonnull responseObject) {
        NSData* data = [[NSData alloc] initWithBase64EncodedString:responseObject options:0];
        self.erwmImagView.image = [UIImage imageWithData:data];
        
    } failure:^(NSError * _Nonnull error) {
        DLog(@"++++++++%@",error);
        
    }];
}
-(UIView *)bgView{
    if (!_bgView) {
        self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        self.bgView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6];
        self.changeVoidceSet = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changeVoidceSet:)];
        [self.bgView addGestureRecognizer:self.changeVoidceSet];
        [self.bgView addSubview:self.erwmView];
        [self.bgView addSubview:self.buttonImag];
    }
    return _bgView;
}
- (UIView *)erwmView{
    if (!_erwmView) {
        self.erwmView = [[UIView alloc] initWithFrame:CGRectMake(20, (SCREEN_HEIGHT - SCREEN_WIDTH - 40)/2, SCREEN_WIDTH - 40, SCREEN_WIDTH - 40)];
        self.erwmView.backgroundColor = [UIColor whiteColor];
        [self.erwmView addSubview:self.infroLabel];
        [self.erwmView addSubview:self.zhAddLabel];
        [self.erwmView addSubview:self.zhDetileAddLabel];
        [self.erwmView addSubview:self.xhAddLabel];
        [self.erwmView addSubview:self.xhDetileAddLabel];
        [self.erwmView addSubview:self.zhStateTime];
        [self.erwmView addSubview:self.xhEndTime];
        [self.erwmView addSubview:self.erwmImagView];
        self.erwmView.layer.masksToBounds = YES;
        self.erwmView.layer.cornerRadius = 10;
    }
    return _erwmView;
}
- (UILabel *)infroLabel{
    if(!_infroLabel){
        self.infroLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 5, SCREEN_WIDTH - 55, 20)];
        self.infroLabel.textColor = [UIColor cjSubheadTextColor];
        self.infroLabel.font = [UIFont systemFontOfSize:15];
    }
    return _infroLabel;
}
- (UILabel *)zhAddLabel{
    if(!_zhAddLabel){
        self.zhAddLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(self.infroLabel.frame) + 5, SCREEN_WIDTH - 55, 20)];
        self.zhAddLabel.textColor = [UIColor cjSubheadTextColor];
        self.zhAddLabel.font = [UIFont systemFontOfSize:15];
    }
    return _zhAddLabel;
}
- (UILabel *)zhDetileAddLabel{
    if(!_zhDetileAddLabel){
        self.zhDetileAddLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(self.zhAddLabel.frame) + 5, SCREEN_WIDTH - 55, 20)];
        self.zhDetileAddLabel.textColor = [UIColor cjSubheadTextColor];
        self.zhDetileAddLabel.font = [UIFont systemFontOfSize:15];
    }
    return _zhDetileAddLabel;
}
- (UILabel *)xhAddLabel{
    if(!_xhAddLabel){
        self.xhAddLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(self.zhDetileAddLabel.frame) + 5, SCREEN_WIDTH - 55, 20)];
        self.xhAddLabel.textColor = [UIColor cjSubheadTextColor];
        self.xhAddLabel.font = [UIFont systemFontOfSize:15];
    }
    return _xhAddLabel;
}
- (UILabel *)xhDetileAddLabel{
    if(!_xhDetileAddLabel){
        self.xhDetileAddLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(self.xhAddLabel.frame) + 5, SCREEN_WIDTH - 55, 20)];
        self.xhDetileAddLabel.textColor = [UIColor cjSubheadTextColor];
        self.xhDetileAddLabel.font = [UIFont systemFontOfSize:15];
    }
    return _xhDetileAddLabel;
}
- (UILabel *)zhStateTime{
    if(!_zhStateTime){
        self.zhStateTime = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(self.xhDetileAddLabel.frame) + 5, SCREEN_WIDTH - 55, 20)];
        self.zhStateTime.textColor = [UIColor cjSubheadTextColor];
        self.zhStateTime.font = [UIFont systemFontOfSize:15];
    }
    return _zhStateTime;
}
- (UILabel *)xhEndTime{
    if(!_xhEndTime){
        self.xhEndTime = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(self.zhStateTime.frame) + 5, SCREEN_WIDTH - 55, 20)];
        self.xhEndTime.textColor = [UIColor cjSubheadTextColor];;
        self.xhEndTime.font = [UIFont systemFontOfSize:15];
    }
    return _xhEndTime;
}
- (UIImageView *)erwmImagView{
    if (!_erwmImagView) {
        self.erwmImagView = [[UIImageView alloc] initWithFrame:CGRectMake(((SCREEN_WIDTH - 40) - (SCREEN_WIDTH -220))/2 , (SCREEN_WIDTH - 40) - (SCREEN_WIDTH - 220), SCREEN_WIDTH -220, SCREEN_WIDTH - 220)];
//        self.erwmImagView.backgroundColor = [UIColor redColor];
    }
    return _erwmImagView;
}
-(UIButton *)buttonImag{
    if (!_buttonImag) {
        self.buttonImag = [UIButton buttonWithType:(UIButtonTypeSystem)];
        [self.buttonImag setTitle:@"保存图片" forState:(UIControlStateNormal)];
        self.buttonImag.backgroundColor = CJRGBAColor(53, 170, 71, 1);
        [self.buttonImag setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
        self.buttonImag.frame = CGRectMake(20,CGRectGetMaxY(self.erwmView.frame) + 10, SCREEN_WIDTH - 40, 44);
        self.buttonImag.layer.masksToBounds = YES;
        self.buttonImag.layer.cornerRadius = 22;
        [self.buttonImag addTarget:self action:@selector(buttonImagAction) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _buttonImag;
}
- (void)changeVoidceSet:(UITapGestureRecognizer *)sender{
    if(CGRectContainsPoint(self.erwmView.frame, [sender locationInView:self.bgView])){

    }else{
        [self.bgView removeFromSuperview];
        if (self.strIsChangeOrder.intValue == 1) {
            [self pop];
        }else{
            if (self.strIsAgainOrder.intValue == 1) {
                [self pop];
            }else{
                [self popToTabVCAtIndex:1];
            }
        }
    }

}
- (void)buttonImagAction{
        [self.bgView removeFromSuperview];
    //把view生成图片保存
    UIImageWriteToSavedPhotosAlbum([self convertViewToImage:self.erwmView], self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);

}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo;
{
    if (error) {
        [CJAlert showStringDismissWithDelay:@"保存失败"];
        [self.bgView removeFromSuperview];
        if (self.strIsChangeOrder.intValue == 1) {
            [self pop];
        }else{
            if (self.strIsAgainOrder.intValue == 1) {
                [self pop];
            }else{
                [self popToTabVCAtIndex:1];
            }
        }
    } else {
        [CJAlert showStringDismissWithDelay:@"保存成功"];
        [self.bgView removeFromSuperview];
        if (self.strIsChangeOrder.intValue == 1) {
            [self pop];
        }else{
            if (self.strIsAgainOrder.intValue == 1) {
                [self pop];
            }else{
                [self popToTabVCAtIndex:1];
            }
        }
    }
}
- (NSMutableAttributedString *)stringColorStr:(NSString *)str String:(NSString *)string Color:(UIColor*)color{
    //Label不同字显示不同颜色
    NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@",str,string]];
    NSRange redRange = NSMakeRange([[noteStr string] rangeOfString:string].location, [[noteStr string] rangeOfString:string].length);
    //需要设置的位置
    [noteStr addAttribute:NSForegroundColorAttributeName value:color range:redRange];
    return noteStr;
}
- (UIImage*)convertViewToImage:(UIView*)v{
    CGSize s = v.bounds.size;
    // 下面方法，第一个参数表示区域大小。第二个参数表示是否是非透明的。如果需要显示半透明效果，需要传NO，否则传YES。第三个参数就是屏幕密度了
    UIGraphicsBeginImageContextWithOptions(s, NO, [UIScreen mainScreen].scale);
    [v.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage*image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

@end
